Files
fstester/setter/src/os2/dirdepth.c

82 lines
2.2 KiB
C
Raw Normal View History

/****************************************************************************
2020-03-01 16:56:27 +00:00
Aaru Data Preservation Suite
-----------------------------------------------------------------------------
2021-03-14 19:14:41 +00:00
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,
2021-03-09 04:42:30 +00:00
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/>.
-----------------------------------------------------------------------------
2020-12-31 23:13:50 +00:00
Copyright (C) 2011-2021 Natalia Portillo
*****************************************************************************/
2021-03-11 22:35:45 +00:00
#define INCL_DOSMISC
#define INCL_DOSFILEMGR
#include <os2.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
2021-03-14 18:51:47 +00:00
#include "../include/consts.h"
#include "../include/defs.h"
2021-03-12 00:05:02 +00:00
#include "os2.h"
2021-03-11 22:35:45 +00:00
void DirectoryDepth(const char* path)
{
char drivePath[4];
2021-03-12 00:05:02 +00:00
APIRET rc = 0;
2021-03-11 22:35:45 +00:00
char filename[9];
2021-03-14 18:51:47 +00:00
int pos = 2;
2021-03-11 22:35:45 +00:00
drivePath[0] = path[0];
drivePath[1] = ':';
drivePath[2] = '\\';
drivePath[3] = 0;
2021-03-12 00:05:02 +00:00
rc = __os2_chdir(drivePath);
2021-03-11 22:35:45 +00:00
if(rc)
{
printf("Cannot change to specified path, not continuing.\n");
return;
}
2021-03-12 00:05:02 +00:00
rc = __os2_mkdir("DEPTH");
2021-03-11 22:35:45 +00:00
if(rc)
{
printf("Cannot create working directory.\n");
return;
}
2021-03-12 00:05:02 +00:00
rc = __os2_chdir("DEPTH");
2021-03-11 22:35:45 +00:00
printf("Creating deepest directory tree.\n");
while(!rc)
{
2021-03-14 18:12:56 +00:00
memset(filename, 0, 9);
sprintf(filename, "%08d", pos);
2021-03-12 00:05:02 +00:00
rc = __os2_mkdir(filename);
2021-03-11 22:35:45 +00:00
2021-03-12 00:05:02 +00:00
if(!rc) rc = __os2_chdir(filename);
2021-03-11 22:35:45 +00:00
pos++;
}
printf("\tCreated %d levels of directory hierarchy\n", pos);
}