mirror of
https://github.com/aaru-dps/fstester.git
synced 2025-12-16 19:24:39 +00:00
83 lines
2.3 KiB
C
83 lines
2.3 KiB
C
/****************************************************************************
|
|
Aaru Data Preservation Suite
|
|
-----------------------------------------------------------------------------
|
|
|
|
Author(s) : Natalia Portillo
|
|
|
|
--[ License ] ---------------------------------------------------------------
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as
|
|
published by the Free Software Foundation, either version 3 of the
|
|
License, or (at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
-----------------------------------------------------------------------------
|
|
Copyright (C) 2011-2021 Natalia Portillo
|
|
*****************************************************************************/
|
|
|
|
#include <proto/dos.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#if defined(__amigaos4__)
|
|
#include <dos/obsolete.h>
|
|
#endif
|
|
|
|
#include "../include/defs.h"
|
|
#include "../log.h"
|
|
|
|
void DirectoryDepth(const char* path)
|
|
{
|
|
int ret;
|
|
char filename[9];
|
|
long pos = 2;
|
|
BPTR pathLock;
|
|
BPTR dirLock;
|
|
|
|
pathLock = Lock((CONST_STRPTR)path, SHARED_LOCK);
|
|
|
|
if(!pathLock)
|
|
{
|
|
log_write("Error %d changing to specified path.\n", IoErr());
|
|
return;
|
|
}
|
|
|
|
CurrentDir(pathLock);
|
|
|
|
dirLock = CreateDir((CONST_STRPTR) "DEPTH");
|
|
|
|
if(!dirLock)
|
|
{
|
|
log_write("Error %d creating working directory.\n", IoErr());
|
|
return;
|
|
}
|
|
|
|
CurrentDir(dirLock);
|
|
|
|
log_write("Creating deepest directory tree.\n");
|
|
|
|
while(!ret)
|
|
{
|
|
memset(filename, 0, 9);
|
|
sprintf(filename, "%08ld", pos);
|
|
dirLock = CreateDir((CONST_STRPTR)filename);
|
|
|
|
if(!dirLock) break;
|
|
|
|
CurrentDir(dirLock);
|
|
|
|
pos++;
|
|
|
|
// This can continue until the disk fills, the kernel crashes, or some other nasty success
|
|
if(pos >= 1000) break;
|
|
}
|
|
|
|
log_write("\tCreated %ld levels of directory hierarchy\n", pos);
|
|
}
|