mirror of
https://github.com/aaru-dps/fstester.git
synced 2025-12-16 19:24:39 +00:00
Merge OS/2 attribute code.
This commit is contained in:
@@ -1,428 +0,0 @@
|
||||
/****************************************************************************
|
||||
Aaru Data Preservation Suite
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Filename : os2_16.c
|
||||
Author(s) : Natalia Portillo
|
||||
|
||||
--[ Description ] -----------------------------------------------------------
|
||||
|
||||
Contains 16-bit OS/2 code
|
||||
|
||||
--[ 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
|
||||
*****************************************************************************/
|
||||
|
||||
#if(defined(__I86__) || defined(__i86__) || defined(_M_I86)) && (defined(__OS2__) || defined(__os2__)) && \
|
||||
!defined(__DOS__)
|
||||
|
||||
#define INCL_DOSMISC
|
||||
#define INCL_DOSFILEMGR
|
||||
|
||||
#include <os2.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../os2.h"
|
||||
#include "include/consts.h"
|
||||
#include "include/defs.h"
|
||||
|
||||
void FileAttributes(const char* path)
|
||||
{
|
||||
char drivePath[4];
|
||||
USHORT rc = 0, wRc = 0, cRc = 0;
|
||||
USHORT actionTaken = 0;
|
||||
HFILE handle;
|
||||
|
||||
drivePath[0] = path[0];
|
||||
drivePath[1] = ':';
|
||||
drivePath[2] = '\\';
|
||||
drivePath[3] = 0;
|
||||
|
||||
rc = DosChDir(drivePath, 0);
|
||||
|
||||
if(rc)
|
||||
{
|
||||
printf("Cannot change to specified path, not continuing.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
rc = DosMkDir("ATTRS", 0);
|
||||
|
||||
if(rc)
|
||||
{
|
||||
printf("Cannot create working directory.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
rc = DosChDir("ATTRS", 0);
|
||||
|
||||
printf("Creating attributes files.\n");
|
||||
|
||||
rc = DosOpen("NONE",
|
||||
&handle,
|
||||
&actionTaken,
|
||||
0,
|
||||
FILE_NORMAL,
|
||||
OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS,
|
||||
OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
|
||||
0);
|
||||
|
||||
if(!rc)
|
||||
{
|
||||
wRc = DosWrite(handle, (PVOID)noAttributeText, strlen(noAttributeText), &actionTaken);
|
||||
cRc = DosClose(handle);
|
||||
rc = DosSetFileMode("NONE", FILE_NORMAL, 0);
|
||||
}
|
||||
|
||||
printf("\tFile with no attributes: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "NONE", rc, wRc, cRc);
|
||||
|
||||
rc = DosOpen("ARCHIVE",
|
||||
&handle,
|
||||
&actionTaken,
|
||||
0,
|
||||
FILE_NORMAL,
|
||||
OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS,
|
||||
OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
|
||||
0);
|
||||
|
||||
if(!rc)
|
||||
{
|
||||
wRc = DosWrite(handle, (PVOID)archivedAttributeText, strlen(archivedAttributeText), &actionTaken);
|
||||
cRc = DosClose(handle);
|
||||
rc = DosSetFileMode("ARCHIVE", FILE_ARCHIVED, 0);
|
||||
}
|
||||
|
||||
printf("\tFile with archived attribute: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "ARCHIVE", rc, wRc, cRc);
|
||||
|
||||
rc = DosOpen("SYSTEM",
|
||||
&handle,
|
||||
&actionTaken,
|
||||
0,
|
||||
FILE_NORMAL,
|
||||
OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS,
|
||||
OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
|
||||
0);
|
||||
|
||||
if(!rc)
|
||||
{
|
||||
wRc = DosWrite(handle, (PVOID)systemAttributeText, strlen(systemAttributeText), &actionTaken);
|
||||
cRc = DosClose(handle);
|
||||
rc = DosSetFileMode("SYSTEM", FILE_SYSTEM, 0);
|
||||
}
|
||||
|
||||
printf("\tFile with system attribute: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "SYSTEM", rc, wRc, cRc);
|
||||
|
||||
rc = DosOpen("HIDDEN",
|
||||
&handle,
|
||||
&actionTaken,
|
||||
0,
|
||||
FILE_NORMAL,
|
||||
OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS,
|
||||
OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
|
||||
0);
|
||||
|
||||
if(!rc)
|
||||
{
|
||||
wRc = DosWrite(handle, (PVOID)hiddenAttributeText, strlen(hiddenAttributeText), &actionTaken);
|
||||
cRc = DosClose(handle);
|
||||
rc = DosSetFileMode("HIDDEN", FILE_HIDDEN, 0);
|
||||
}
|
||||
|
||||
printf("\tFile with hidden attribute: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "HIDDEN", rc, wRc, cRc);
|
||||
|
||||
rc = DosOpen("READONLY",
|
||||
&handle,
|
||||
&actionTaken,
|
||||
0,
|
||||
FILE_NORMAL,
|
||||
OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS,
|
||||
OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
|
||||
0);
|
||||
|
||||
if(!rc)
|
||||
{
|
||||
wRc = DosWrite(handle, (PVOID)readonlyAttributeText, strlen(readonlyAttributeText), &actionTaken);
|
||||
cRc = DosClose(handle);
|
||||
rc = DosSetFileMode("READONLY", FILE_READONLY, 0);
|
||||
}
|
||||
|
||||
printf("\tFile with read-only attribute: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "READONLY", rc, wRc, cRc);
|
||||
|
||||
rc = DosOpen("HIDDREAD",
|
||||
&handle,
|
||||
&actionTaken,
|
||||
0,
|
||||
FILE_NORMAL,
|
||||
OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS,
|
||||
OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
|
||||
0);
|
||||
|
||||
if(!rc)
|
||||
{
|
||||
wRc = DosWrite(handle, (PVOID)hiddenAttributeText, strlen(hiddenAttributeText), &actionTaken);
|
||||
wRc = DosWrite(handle, (PVOID)readonlyAttributeText, strlen(readonlyAttributeText), &actionTaken);
|
||||
cRc = DosClose(handle);
|
||||
rc = DosSetFileMode("HIDDREAD", FILE_HIDDEN | FILE_READONLY, 0);
|
||||
}
|
||||
|
||||
printf("\tFile with hidden, read-only attributes: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n",
|
||||
"HIDDREAD",
|
||||
rc,
|
||||
wRc,
|
||||
cRc);
|
||||
|
||||
rc = DosOpen("SYSTREAD",
|
||||
&handle,
|
||||
&actionTaken,
|
||||
0,
|
||||
FILE_NORMAL,
|
||||
OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS,
|
||||
OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
|
||||
0);
|
||||
|
||||
if(!rc)
|
||||
{
|
||||
wRc = DosWrite(handle, (PVOID)systemAttributeText, strlen(systemAttributeText), &actionTaken);
|
||||
wRc = DosWrite(handle, (PVOID)readonlyAttributeText, strlen(readonlyAttributeText), &actionTaken);
|
||||
cRc = DosClose(handle);
|
||||
rc = DosSetFileMode("SYSTREAD", FILE_SYSTEM | FILE_READONLY, 0);
|
||||
}
|
||||
|
||||
printf("\tFile with system, read-only attributes: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n",
|
||||
"SYSTREAD",
|
||||
rc,
|
||||
wRc,
|
||||
cRc);
|
||||
|
||||
rc = DosOpen("SYSTHIDD",
|
||||
&handle,
|
||||
&actionTaken,
|
||||
0,
|
||||
FILE_NORMAL,
|
||||
OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS,
|
||||
OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
|
||||
0);
|
||||
|
||||
if(!rc)
|
||||
{
|
||||
wRc = DosWrite(handle, (PVOID)systemAttributeText, strlen(systemAttributeText), &actionTaken);
|
||||
wRc = DosWrite(handle, (PVOID)hiddenAttributeText, strlen(hiddenAttributeText), &actionTaken);
|
||||
cRc = DosClose(handle);
|
||||
rc = DosSetFileMode("SYSTHIDD", FILE_SYSTEM | FILE_HIDDEN, 0);
|
||||
}
|
||||
|
||||
printf("\tFile with system, hidden attributes: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n",
|
||||
"SYSTHIDD",
|
||||
rc,
|
||||
wRc,
|
||||
cRc);
|
||||
|
||||
rc = DosOpen("SYSRDYHD",
|
||||
&handle,
|
||||
&actionTaken,
|
||||
0,
|
||||
FILE_NORMAL,
|
||||
OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS,
|
||||
OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
|
||||
0);
|
||||
|
||||
if(!rc)
|
||||
{
|
||||
wRc = DosWrite(handle, (PVOID)systemAttributeText, strlen(systemAttributeText), &actionTaken);
|
||||
wRc = DosWrite(handle, (PVOID)readonlyAttributeText, strlen(readonlyAttributeText), &actionTaken);
|
||||
wRc = DosWrite(handle, (PVOID)hiddenAttributeText, strlen(hiddenAttributeText), &actionTaken);
|
||||
cRc = DosClose(handle);
|
||||
rc = DosSetFileMode("SYSRDYHD", FILE_SYSTEM | FILE_READONLY | FILE_HIDDEN, 0);
|
||||
}
|
||||
|
||||
printf("\tFile with system, read-only, hidden attributes: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n",
|
||||
"SYSRDYHD",
|
||||
rc,
|
||||
wRc,
|
||||
cRc);
|
||||
|
||||
rc = DosOpen("ARCHREAD",
|
||||
&handle,
|
||||
&actionTaken,
|
||||
0,
|
||||
FILE_NORMAL,
|
||||
OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS,
|
||||
OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
|
||||
0);
|
||||
|
||||
if(!rc)
|
||||
{
|
||||
wRc = DosWrite(handle, (PVOID)archivedAttributeText, strlen(archivedAttributeText), &actionTaken);
|
||||
wRc = DosWrite(handle, (PVOID)readonlyAttributeText, strlen(readonlyAttributeText), &actionTaken);
|
||||
cRc = DosClose(handle);
|
||||
rc = DosSetFileMode("ARCHREAD", FILE_ARCHIVED | FILE_READONLY, 0);
|
||||
}
|
||||
|
||||
printf("\tFile with archived, read-only attributes: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n",
|
||||
"ARCHREAD",
|
||||
rc,
|
||||
wRc,
|
||||
cRc);
|
||||
|
||||
rc = DosOpen("ARCHHIDD",
|
||||
&handle,
|
||||
&actionTaken,
|
||||
0,
|
||||
FILE_NORMAL,
|
||||
OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS,
|
||||
OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
|
||||
0);
|
||||
|
||||
if(!rc)
|
||||
{
|
||||
wRc = DosWrite(handle, (PVOID)archivedAttributeText, strlen(archivedAttributeText), &actionTaken);
|
||||
wRc = DosWrite(handle, (PVOID)hiddenAttributeText, strlen(hiddenAttributeText), &actionTaken);
|
||||
cRc = DosClose(handle);
|
||||
rc = DosSetFileMode("ARCHHIDD", FILE_ARCHIVED | FILE_HIDDEN, 0);
|
||||
}
|
||||
|
||||
printf("\tFile with archived, hidden attributes: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n",
|
||||
"ARCHHIDD",
|
||||
rc,
|
||||
wRc,
|
||||
cRc);
|
||||
|
||||
rc = DosOpen("ARCHDRDY",
|
||||
&handle,
|
||||
&actionTaken,
|
||||
0,
|
||||
FILE_NORMAL,
|
||||
OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS,
|
||||
OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
|
||||
0);
|
||||
|
||||
if(!rc)
|
||||
{
|
||||
wRc = DosWrite(handle, (PVOID)archivedAttributeText, strlen(archivedAttributeText), &actionTaken);
|
||||
wRc = DosWrite(handle, (PVOID)hiddenAttributeText, strlen(hiddenAttributeText), &actionTaken);
|
||||
wRc = DosWrite(handle, (PVOID)readonlyAttributeText, strlen(readonlyAttributeText), &actionTaken);
|
||||
cRc = DosClose(handle);
|
||||
rc = DosSetFileMode("ARCHDRDY", FILE_ARCHIVED | FILE_HIDDEN | FILE_READONLY, 0);
|
||||
}
|
||||
|
||||
printf("\tFile with archived, hidden, read-only attributes: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n",
|
||||
"ARCHDRDY",
|
||||
rc,
|
||||
wRc,
|
||||
cRc);
|
||||
|
||||
rc = DosOpen("ARCHSYST",
|
||||
&handle,
|
||||
&actionTaken,
|
||||
0,
|
||||
FILE_NORMAL,
|
||||
OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS,
|
||||
OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
|
||||
0);
|
||||
|
||||
if(!rc)
|
||||
{
|
||||
wRc = DosWrite(handle, (PVOID)archivedAttributeText, strlen(archivedAttributeText), &actionTaken);
|
||||
wRc = DosWrite(handle, (PVOID)systemAttributeText, strlen(systemAttributeText), &actionTaken);
|
||||
cRc = DosClose(handle);
|
||||
rc = DosSetFileMode("ARCHSYST", FILE_ARCHIVED | FILE_SYSTEM, 0);
|
||||
}
|
||||
|
||||
printf("\tFile with archived, system attributes: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n",
|
||||
"ARCHSYST",
|
||||
rc,
|
||||
wRc,
|
||||
cRc);
|
||||
|
||||
rc = DosOpen("ARSYSRDY",
|
||||
&handle,
|
||||
&actionTaken,
|
||||
0,
|
||||
FILE_NORMAL,
|
||||
OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS,
|
||||
OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
|
||||
0);
|
||||
|
||||
if(!rc)
|
||||
{
|
||||
wRc = DosWrite(handle, (PVOID)archivedAttributeText, strlen(archivedAttributeText), &actionTaken);
|
||||
wRc = DosWrite(handle, (PVOID)systemAttributeText, strlen(systemAttributeText), &actionTaken);
|
||||
wRc = DosWrite(handle, (PVOID)readonlyAttributeText, strlen(readonlyAttributeText), &actionTaken);
|
||||
cRc = DosClose(handle);
|
||||
rc = DosSetFileMode("ARSYSRDY", FILE_ARCHIVED | FILE_SYSTEM | FILE_READONLY, 0);
|
||||
}
|
||||
|
||||
printf("\tFile with archived, system, read-only attributes: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n",
|
||||
"ARSYSRDY",
|
||||
rc,
|
||||
wRc,
|
||||
cRc);
|
||||
|
||||
rc = DosOpen("ARCSYSHD",
|
||||
&handle,
|
||||
&actionTaken,
|
||||
0,
|
||||
FILE_NORMAL,
|
||||
OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS,
|
||||
OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
|
||||
0);
|
||||
|
||||
if(!rc)
|
||||
{
|
||||
wRc = DosWrite(handle, (PVOID)archivedAttributeText, strlen(archivedAttributeText), &actionTaken);
|
||||
wRc = DosWrite(handle, (PVOID)systemAttributeText, strlen(systemAttributeText), &actionTaken);
|
||||
wRc = DosWrite(handle, (PVOID)hiddenAttributeText, strlen(hiddenAttributeText), &actionTaken);
|
||||
cRc = DosClose(handle);
|
||||
rc = DosSetFileMode("ARCSYSHD", FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN, 0);
|
||||
}
|
||||
|
||||
printf("\tFile with archived, system, hidden attributes: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n",
|
||||
"ARCSYSHD",
|
||||
rc,
|
||||
wRc,
|
||||
cRc);
|
||||
|
||||
rc = DosOpen("ARSYHDRD",
|
||||
&handle,
|
||||
&actionTaken,
|
||||
0,
|
||||
FILE_NORMAL,
|
||||
OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS,
|
||||
OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
|
||||
0);
|
||||
|
||||
if(!rc)
|
||||
{
|
||||
wRc = DosWrite(handle, (PVOID)archivedAttributeText, strlen(archivedAttributeText), &actionTaken);
|
||||
wRc = DosWrite(handle, (PVOID)systemAttributeText, strlen(systemAttributeText), &actionTaken);
|
||||
wRc = DosWrite(handle, (PVOID)hiddenAttributeText, strlen(hiddenAttributeText), &actionTaken);
|
||||
wRc = DosWrite(handle, (PVOID)readonlyAttributeText, strlen(readonlyAttributeText), &actionTaken);
|
||||
cRc = DosClose(handle);
|
||||
rc = DosSetFileMode("ARSYHDRD", FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN | FILE_READONLY, 0);
|
||||
}
|
||||
|
||||
printf("\tFile with all (archived, system, hidden, read-only) attributes: name = \"%s\", rc = %d, wRc = %d, cRc = "
|
||||
"%d\n",
|
||||
"ARSYHDRD",
|
||||
rc,
|
||||
wRc,
|
||||
cRc);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,445 +0,0 @@
|
||||
/****************************************************************************
|
||||
Aaru Data Preservation Suite
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Filename : os2_32.c
|
||||
Author(s) : Natalia Portillo
|
||||
|
||||
--[ Description ] -----------------------------------------------------------
|
||||
|
||||
Contains 32-bit OS/2 code
|
||||
|
||||
--[ 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
|
||||
*****************************************************************************/
|
||||
|
||||
#if(defined(__I386__) || defined(__i386__) || defined(__THW_INTEL) || defined(_M_I386)) && \
|
||||
(defined(__OS2__) || defined(__os2__)) && !defined(__DOS__)
|
||||
|
||||
#define INCL_DOSMISC
|
||||
#define INCL_DOSFILEMGR
|
||||
|
||||
#include <os2.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../os2.h"
|
||||
#include "include/consts.h"
|
||||
#include "include/defs.h"
|
||||
|
||||
void FileAttributes(const char* path)
|
||||
{
|
||||
char drivePath[4];
|
||||
APIRET rc = 0, wRc = 0, cRc = 0;
|
||||
ULONG actionTaken = 0;
|
||||
HFILE handle;
|
||||
FILESTATUS3 fileStatus = {{0}};
|
||||
|
||||
drivePath[0] = path[0];
|
||||
drivePath[1] = ':';
|
||||
drivePath[2] = '\\';
|
||||
drivePath[3] = 0;
|
||||
|
||||
rc = DosSetCurrentDir(drivePath);
|
||||
|
||||
if(rc)
|
||||
{
|
||||
printf("Cannot change to specified path, not continuing.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
rc = DosCreateDir("ATTRS", NULL);
|
||||
|
||||
if(rc)
|
||||
{
|
||||
printf("Cannot create working directory.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
rc = DosSetCurrentDir("ATTRS");
|
||||
|
||||
printf("Creating attributes files.\n");
|
||||
|
||||
rc = DosOpen("NONE",
|
||||
&handle,
|
||||
&actionTaken,
|
||||
0,
|
||||
FILE_NORMAL,
|
||||
OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS,
|
||||
OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
|
||||
0);
|
||||
|
||||
if(!rc)
|
||||
{
|
||||
wRc = DosWrite(handle, (PVOID)noAttributeText, strlen(noAttributeText), &actionTaken);
|
||||
fileStatus.attrFile = FILE_NORMAL;
|
||||
rc = DosSetFileInfo(handle, FIL_STANDARD, &fileStatus, sizeof(FILESTATUS3));
|
||||
cRc = DosClose(handle);
|
||||
}
|
||||
|
||||
printf("\tFile with no attributes: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "NONE", rc, wRc, cRc);
|
||||
|
||||
rc = DosOpen("ARCHIVE",
|
||||
&handle,
|
||||
&actionTaken,
|
||||
0,
|
||||
FILE_NORMAL,
|
||||
OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS,
|
||||
OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
|
||||
0);
|
||||
|
||||
if(!rc)
|
||||
{
|
||||
wRc = DosWrite(handle, (PVOID)archivedAttributeText, strlen(archivedAttributeText), &actionTaken);
|
||||
fileStatus.attrFile = FILE_ARCHIVED;
|
||||
rc = DosSetFileInfo(handle, FIL_STANDARD, &fileStatus, sizeof(FILESTATUS3));
|
||||
cRc = DosClose(handle);
|
||||
}
|
||||
|
||||
printf("\tFile with archived attribute: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "ARCHIVE", rc, wRc, cRc);
|
||||
|
||||
rc = DosOpen("SYSTEM",
|
||||
&handle,
|
||||
&actionTaken,
|
||||
0,
|
||||
FILE_NORMAL,
|
||||
OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS,
|
||||
OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
|
||||
0);
|
||||
|
||||
if(!rc)
|
||||
{
|
||||
wRc = DosWrite(handle, (PVOID)systemAttributeText, strlen(systemAttributeText), &actionTaken);
|
||||
fileStatus.attrFile = FILE_SYSTEM;
|
||||
rc = DosSetFileInfo(handle, FIL_STANDARD, &fileStatus, sizeof(FILESTATUS3));
|
||||
cRc = DosClose(handle);
|
||||
}
|
||||
|
||||
printf("\tFile with system attribute: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "SYSTEM", rc, wRc, cRc);
|
||||
|
||||
rc = DosOpen("HIDDEN",
|
||||
&handle,
|
||||
&actionTaken,
|
||||
0,
|
||||
FILE_NORMAL,
|
||||
OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS,
|
||||
OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
|
||||
0);
|
||||
|
||||
if(!rc)
|
||||
{
|
||||
wRc = DosWrite(handle, (PVOID)hiddenAttributeText, strlen(hiddenAttributeText), &actionTaken);
|
||||
fileStatus.attrFile = FILE_HIDDEN;
|
||||
rc = DosSetFileInfo(handle, FIL_STANDARD, &fileStatus, sizeof(FILESTATUS3));
|
||||
cRc = DosClose(handle);
|
||||
}
|
||||
|
||||
printf("\tFile with hidden attribute: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "HIDDEN", rc, wRc, cRc);
|
||||
|
||||
rc = DosOpen("READONLY",
|
||||
&handle,
|
||||
&actionTaken,
|
||||
0,
|
||||
FILE_NORMAL,
|
||||
OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS,
|
||||
OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
|
||||
0);
|
||||
|
||||
if(!rc)
|
||||
{
|
||||
wRc = DosWrite(handle, (PVOID)readonlyAttributeText, strlen(readonlyAttributeText), &actionTaken);
|
||||
fileStatus.attrFile = FILE_READONLY;
|
||||
rc = DosSetFileInfo(handle, FIL_STANDARD, &fileStatus, sizeof(FILESTATUS3));
|
||||
cRc = DosClose(handle);
|
||||
}
|
||||
|
||||
printf("\tFile with read-only attribute: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "READONLY", rc, wRc, cRc);
|
||||
|
||||
rc = DosOpen("HIDDREAD",
|
||||
&handle,
|
||||
&actionTaken,
|
||||
0,
|
||||
FILE_NORMAL,
|
||||
OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS,
|
||||
OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
|
||||
0);
|
||||
|
||||
if(!rc)
|
||||
{
|
||||
wRc = DosWrite(handle, (PVOID)hiddenAttributeText, strlen(hiddenAttributeText), &actionTaken);
|
||||
wRc = DosWrite(handle, (PVOID)readonlyAttributeText, strlen(readonlyAttributeText), &actionTaken);
|
||||
fileStatus.attrFile = FILE_HIDDEN | FILE_READONLY;
|
||||
rc = DosSetFileInfo(handle, FIL_STANDARD, &fileStatus, sizeof(FILESTATUS3));
|
||||
cRc = DosClose(handle);
|
||||
}
|
||||
|
||||
printf("\tFile with hidden, read-only attributes: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n",
|
||||
"HIDDREAD",
|
||||
rc,
|
||||
wRc,
|
||||
cRc);
|
||||
|
||||
rc = DosOpen("SYSTREAD",
|
||||
&handle,
|
||||
&actionTaken,
|
||||
0,
|
||||
FILE_NORMAL,
|
||||
OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS,
|
||||
OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
|
||||
0);
|
||||
|
||||
if(!rc)
|
||||
{
|
||||
wRc = DosWrite(handle, (PVOID)systemAttributeText, strlen(systemAttributeText), &actionTaken);
|
||||
wRc = DosWrite(handle, (PVOID)readonlyAttributeText, strlen(readonlyAttributeText), &actionTaken);
|
||||
fileStatus.attrFile = FILE_SYSTEM | FILE_READONLY;
|
||||
rc = DosSetFileInfo(handle, FIL_STANDARD, &fileStatus, sizeof(FILESTATUS3));
|
||||
cRc = DosClose(handle);
|
||||
}
|
||||
|
||||
printf("\tFile with system, read-only attributes: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n",
|
||||
"SYSTREAD",
|
||||
rc,
|
||||
wRc,
|
||||
cRc);
|
||||
|
||||
rc = DosOpen("SYSTHIDD",
|
||||
&handle,
|
||||
&actionTaken,
|
||||
0,
|
||||
FILE_NORMAL,
|
||||
OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS,
|
||||
OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
|
||||
0);
|
||||
|
||||
if(!rc)
|
||||
{
|
||||
wRc = DosWrite(handle, (PVOID)systemAttributeText, strlen(systemAttributeText), &actionTaken);
|
||||
wRc = DosWrite(handle, (PVOID)hiddenAttributeText, strlen(hiddenAttributeText), &actionTaken);
|
||||
fileStatus.attrFile = FILE_SYSTEM | FILE_HIDDEN;
|
||||
rc = DosSetFileInfo(handle, FIL_STANDARD, &fileStatus, sizeof(FILESTATUS3));
|
||||
cRc = DosClose(handle);
|
||||
}
|
||||
|
||||
printf("\tFile with system, hidden attributes: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n",
|
||||
"SYSTHIDD",
|
||||
rc,
|
||||
wRc,
|
||||
cRc);
|
||||
|
||||
rc = DosOpen("SYSRDYHD",
|
||||
&handle,
|
||||
&actionTaken,
|
||||
0,
|
||||
FILE_NORMAL,
|
||||
OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS,
|
||||
OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
|
||||
0);
|
||||
|
||||
if(!rc)
|
||||
{
|
||||
wRc = DosWrite(handle, (PVOID)systemAttributeText, strlen(systemAttributeText), &actionTaken);
|
||||
wRc = DosWrite(handle, (PVOID)readonlyAttributeText, strlen(readonlyAttributeText), &actionTaken);
|
||||
wRc = DosWrite(handle, (PVOID)hiddenAttributeText, strlen(hiddenAttributeText), &actionTaken);
|
||||
fileStatus.attrFile = FILE_SYSTEM | FILE_READONLY | FILE_HIDDEN;
|
||||
rc = DosSetFileInfo(handle, FIL_STANDARD, &fileStatus, sizeof(FILESTATUS3));
|
||||
cRc = DosClose(handle);
|
||||
}
|
||||
|
||||
printf("\tFile with system, read-only, hidden attributes: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n",
|
||||
"SYSRDYHD",
|
||||
rc,
|
||||
wRc,
|
||||
cRc);
|
||||
|
||||
rc = DosOpen("ARCHREAD",
|
||||
&handle,
|
||||
&actionTaken,
|
||||
0,
|
||||
FILE_NORMAL,
|
||||
OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS,
|
||||
OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
|
||||
0);
|
||||
|
||||
if(!rc)
|
||||
{
|
||||
wRc = DosWrite(handle, (PVOID)archivedAttributeText, strlen(archivedAttributeText), &actionTaken);
|
||||
wRc = DosWrite(handle, (PVOID)readonlyAttributeText, strlen(readonlyAttributeText), &actionTaken);
|
||||
fileStatus.attrFile = FILE_ARCHIVED | FILE_READONLY;
|
||||
rc = DosSetFileInfo(handle, FIL_STANDARD, &fileStatus, sizeof(FILESTATUS3));
|
||||
cRc = DosClose(handle);
|
||||
}
|
||||
|
||||
printf("\tFile with archived, read-only attributes: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n",
|
||||
"ARCHREAD",
|
||||
rc,
|
||||
wRc,
|
||||
cRc);
|
||||
|
||||
rc = DosOpen("ARCHHIDD",
|
||||
&handle,
|
||||
&actionTaken,
|
||||
0,
|
||||
FILE_NORMAL,
|
||||
OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS,
|
||||
OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
|
||||
0);
|
||||
|
||||
if(!rc)
|
||||
{
|
||||
wRc = DosWrite(handle, (PVOID)archivedAttributeText, strlen(archivedAttributeText), &actionTaken);
|
||||
wRc = DosWrite(handle, (PVOID)hiddenAttributeText, strlen(hiddenAttributeText), &actionTaken);
|
||||
fileStatus.attrFile = FILE_ARCHIVED | FILE_HIDDEN;
|
||||
rc = DosSetFileInfo(handle, FIL_STANDARD, &fileStatus, sizeof(FILESTATUS3));
|
||||
cRc = DosClose(handle);
|
||||
}
|
||||
|
||||
printf("\tFile with archived, hidden attributes: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n",
|
||||
"ARCHHIDD",
|
||||
rc,
|
||||
wRc,
|
||||
cRc);
|
||||
|
||||
rc = DosOpen("ARCHDRDY",
|
||||
&handle,
|
||||
&actionTaken,
|
||||
0,
|
||||
FILE_NORMAL,
|
||||
OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS,
|
||||
OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
|
||||
0);
|
||||
|
||||
if(!rc)
|
||||
{
|
||||
wRc = DosWrite(handle, (PVOID)archivedAttributeText, strlen(archivedAttributeText), &actionTaken);
|
||||
wRc = DosWrite(handle, (PVOID)hiddenAttributeText, strlen(hiddenAttributeText), &actionTaken);
|
||||
wRc = DosWrite(handle, (PVOID)readonlyAttributeText, strlen(readonlyAttributeText), &actionTaken);
|
||||
fileStatus.attrFile = FILE_ARCHIVED | FILE_HIDDEN | FILE_READONLY;
|
||||
rc = DosSetFileInfo(handle, FIL_STANDARD, &fileStatus, sizeof(FILESTATUS3));
|
||||
cRc = DosClose(handle);
|
||||
}
|
||||
|
||||
printf("\tFile with archived, hidden, read-only attributes: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n",
|
||||
"ARCHDRDY",
|
||||
rc,
|
||||
wRc,
|
||||
cRc);
|
||||
|
||||
rc = DosOpen("ARCHSYST",
|
||||
&handle,
|
||||
&actionTaken,
|
||||
0,
|
||||
FILE_NORMAL,
|
||||
OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS,
|
||||
OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
|
||||
0);
|
||||
|
||||
if(!rc)
|
||||
{
|
||||
wRc = DosWrite(handle, (PVOID)archivedAttributeText, strlen(archivedAttributeText), &actionTaken);
|
||||
wRc = DosWrite(handle, (PVOID)systemAttributeText, strlen(systemAttributeText), &actionTaken);
|
||||
fileStatus.attrFile = FILE_ARCHIVED | FILE_SYSTEM;
|
||||
rc = DosSetFileInfo(handle, FIL_STANDARD, &fileStatus, sizeof(FILESTATUS3));
|
||||
cRc = DosClose(handle);
|
||||
}
|
||||
|
||||
printf("\tFile with archived, system attributes: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n",
|
||||
"ARCHSYST",
|
||||
rc,
|
||||
wRc,
|
||||
cRc);
|
||||
|
||||
rc = DosOpen("ARSYSRDY",
|
||||
&handle,
|
||||
&actionTaken,
|
||||
0,
|
||||
FILE_NORMAL,
|
||||
OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS,
|
||||
OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
|
||||
0);
|
||||
|
||||
if(!rc)
|
||||
{
|
||||
wRc = DosWrite(handle, (PVOID)archivedAttributeText, strlen(archivedAttributeText), &actionTaken);
|
||||
wRc = DosWrite(handle, (PVOID)systemAttributeText, strlen(systemAttributeText), &actionTaken);
|
||||
wRc = DosWrite(handle, (PVOID)readonlyAttributeText, strlen(readonlyAttributeText), &actionTaken);
|
||||
fileStatus.attrFile = FILE_ARCHIVED | FILE_SYSTEM | FILE_READONLY;
|
||||
rc = DosSetFileInfo(handle, FIL_STANDARD, &fileStatus, sizeof(FILESTATUS3));
|
||||
cRc = DosClose(handle);
|
||||
}
|
||||
|
||||
printf("\tFile with archived, system, read-only attributes: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n",
|
||||
"ARSYSRDY",
|
||||
rc,
|
||||
wRc,
|
||||
cRc);
|
||||
|
||||
rc = DosOpen("ARCSYSHD",
|
||||
&handle,
|
||||
&actionTaken,
|
||||
0,
|
||||
FILE_NORMAL,
|
||||
OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS,
|
||||
OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
|
||||
0);
|
||||
|
||||
if(!rc)
|
||||
{
|
||||
wRc = DosWrite(handle, (PVOID)archivedAttributeText, strlen(archivedAttributeText), &actionTaken);
|
||||
wRc = DosWrite(handle, (PVOID)systemAttributeText, strlen(systemAttributeText), &actionTaken);
|
||||
wRc = DosWrite(handle, (PVOID)hiddenAttributeText, strlen(hiddenAttributeText), &actionTaken);
|
||||
fileStatus.attrFile = FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN;
|
||||
rc = DosSetFileInfo(handle, FIL_STANDARD, &fileStatus, sizeof(FILESTATUS3));
|
||||
cRc = DosClose(handle);
|
||||
}
|
||||
|
||||
printf("\tFile with archived, system, hidden attributes: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n",
|
||||
"ARCSYSHD",
|
||||
rc,
|
||||
wRc,
|
||||
cRc);
|
||||
|
||||
rc = DosOpen("ARSYHDRD",
|
||||
&handle,
|
||||
&actionTaken,
|
||||
0,
|
||||
FILE_NORMAL,
|
||||
OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS,
|
||||
OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
|
||||
0);
|
||||
|
||||
if(!rc)
|
||||
{
|
||||
wRc = DosWrite(handle, (PVOID)archivedAttributeText, strlen(archivedAttributeText), &actionTaken);
|
||||
wRc = DosWrite(handle, (PVOID)systemAttributeText, strlen(systemAttributeText), &actionTaken);
|
||||
wRc = DosWrite(handle, (PVOID)hiddenAttributeText, strlen(hiddenAttributeText), &actionTaken);
|
||||
wRc = DosWrite(handle, (PVOID)readonlyAttributeText, strlen(readonlyAttributeText), &actionTaken);
|
||||
fileStatus.attrFile = FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN | FILE_READONLY;
|
||||
rc = DosSetFileInfo(handle, FIL_STANDARD, &fileStatus, sizeof(FILESTATUS3));
|
||||
cRc = DosClose(handle);
|
||||
}
|
||||
|
||||
printf("\tFile with all (archived, system, hidden, read-only) attributes: name = \"%s\", rc = %d, wRc = %d, cRc = "
|
||||
"%d\n",
|
||||
"ARSYHDRD",
|
||||
rc,
|
||||
wRc,
|
||||
cRc);
|
||||
}
|
||||
|
||||
#endif
|
||||
119
setter/src/os2/attr.c
Normal file
119
setter/src/os2/attr.c
Normal file
@@ -0,0 +1,119 @@
|
||||
/****************************************************************************
|
||||
Aaru Data Preservation Suite
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Filename : attr.c
|
||||
Author(s) : Natalia Portillo
|
||||
|
||||
--[ Description ] -----------------------------------------------------------
|
||||
|
||||
Contains common OS/2 code
|
||||
|
||||
--[ 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
|
||||
*****************************************************************************/
|
||||
|
||||
#define INCL_DOSMISC
|
||||
#define INCL_DOSFILEMGR
|
||||
|
||||
#include <os2.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "attr.h"
|
||||
|
||||
#include "include/consts.h"
|
||||
#include "include/defs.h"
|
||||
#include "os2.h"
|
||||
|
||||
void FileAttributes(const char* path)
|
||||
{
|
||||
char drivePath[4];
|
||||
APIRET rc = 0, wRc = 0, cRc = 0;
|
||||
HFILE handle;
|
||||
int i;
|
||||
|
||||
// 32 bit
|
||||
#if(defined(__I386__) || defined(__i386__) || defined(__THW_INTEL) || defined(_M_I386))
|
||||
ULONG actionTaken = 0;
|
||||
FILESTATUS3 fileStatus = {{0}};
|
||||
#else // 16 bit
|
||||
USHORT actionTaken = 0;
|
||||
#endif
|
||||
|
||||
drivePath[0] = path[0];
|
||||
drivePath[1] = ':';
|
||||
drivePath[2] = '\\';
|
||||
drivePath[3] = 0;
|
||||
|
||||
rc = __os2_chdir(drivePath);
|
||||
|
||||
if(rc)
|
||||
{
|
||||
printf("Cannot change to specified path, not continuing.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
rc = __os2_mkdir("ATTRS");
|
||||
|
||||
if(rc)
|
||||
{
|
||||
printf("Cannot create working directory.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
rc = __os2_chdir("ATTRS");
|
||||
|
||||
printf("Creating attributes files.\n");
|
||||
|
||||
for(i = 0; i < KNOWN_OS2_ATTRS; i++)
|
||||
{
|
||||
rc = DosOpen(os2_attrs[i].filename,
|
||||
&handle,
|
||||
&actionTaken,
|
||||
0,
|
||||
FILE_NORMAL,
|
||||
OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS,
|
||||
OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
|
||||
0);
|
||||
|
||||
if(!rc)
|
||||
{
|
||||
wRc = DosWrite(handle, (PVOID)os2_attrs[i].contents, strlen(os2_attrs[i].contents), &actionTaken);
|
||||
|
||||
// 32 bit
|
||||
#if(defined(__I386__) || defined(__i386__) || defined(__THW_INTEL) || defined(_M_I386))
|
||||
// It operates over the handle so file must be closed after setting attribute
|
||||
fileStatus.attrFile = os2_attrs[i].attr;
|
||||
rc = DosSetFileInfo(handle, FIL_STANDARD, &fileStatus, sizeof(FILESTATUS3));
|
||||
cRc = DosClose(handle);
|
||||
#else // 16 bit
|
||||
// It operates over the filename so file must be closed before setting attribute
|
||||
cRc = DosClose(handle);
|
||||
rc = DosSetFileMode(os2_attrs[i].filename, os2_attrs[i].attr, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
printf("\t%s: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n",
|
||||
os2_attrs[i].description,
|
||||
os2_attrs[i].filename,
|
||||
rc,
|
||||
wRc,
|
||||
cRc);
|
||||
}
|
||||
}
|
||||
87
setter/src/os2/attr.h
Normal file
87
setter/src/os2/attr.h
Normal file
@@ -0,0 +1,87 @@
|
||||
#ifndef SETTER_SRC_OS2_ATTR_H_
|
||||
#define SETTER_SRC_OS2_ATTR_H_
|
||||
|
||||
#include <os2.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char filename[9];
|
||||
char contents[170];
|
||||
char description[63];
|
||||
USHORT attr;
|
||||
} os2_attr_tests_t;
|
||||
|
||||
#define KNOWN_OS2_ATTRS 16
|
||||
|
||||
static const os2_attr_tests_t os2_attrs[KNOWN_OS2_ATTRS] = {
|
||||
{"NONE", "This file has no attribute set.\n", "File with no attributes", FILE_NORMAL},
|
||||
{"ARCHIVE", "This file has the archived attribute set.\n", "File with archived attribute", FILE_ARCHIVED},
|
||||
{"SYSTEM", "This file has the system attribute set.\n", "File with system attribute", FILE_SYSTEM},
|
||||
{"HIDDEN", "This file has the hidden attribute set.\n", "File with hidden attribute", FILE_HIDDEN},
|
||||
{"READONLY", "This file has the read-only attribute set.\n", "File with read-only attribute", FILE_READONLY},
|
||||
{"HIDDREAD",
|
||||
"This file has the hidden attribute set.\n"
|
||||
"This file has the read-only attribute set.\n",
|
||||
"File with hidden, read-only attributes",
|
||||
FILE_HIDDEN | FILE_READONLY},
|
||||
{"SYSTREAD",
|
||||
"This file has the system attribute set.\n"
|
||||
"This file has the read-only attribute set.\n",
|
||||
"File with system, read-only attributes",
|
||||
FILE_SYSTEM | FILE_READONLY},
|
||||
{"SYSTHIDD",
|
||||
"This file has the system attribute set.\n"
|
||||
"This file has the hidden attribute set.\n",
|
||||
"File with system, hidden attributes",
|
||||
FILE_SYSTEM | FILE_HIDDEN},
|
||||
{"SYSRDYHD",
|
||||
"This file has the system attribute set.\n"
|
||||
"This file has the read-only attribute set.\n"
|
||||
"This file has the hidden attribute set.\n",
|
||||
"File with system, read-only, hidden attributes",
|
||||
FILE_SYSTEM | FILE_READONLY | FILE_HIDDEN},
|
||||
{"ARCHREAD",
|
||||
"This file has the archived attribute set.\n"
|
||||
"This file has the read-only attribute set.\n",
|
||||
"File with archived, read-only attributes",
|
||||
FILE_ARCHIVED | FILE_READONLY},
|
||||
{"ARCHHIDD",
|
||||
"This file has the archived attribute set.\n"
|
||||
"This file has the hidden attribute set.\n",
|
||||
"File with archived, hidden attributes",
|
||||
FILE_ARCHIVED | FILE_HIDDEN},
|
||||
{"ARCHDRDY",
|
||||
"This file has the archived attribute set.\n"
|
||||
"This file has the hidden attribute set.\n"
|
||||
"This file has the read-only attribute set.\n",
|
||||
"File with archived, hidden, read-only attributes",
|
||||
FILE_ARCHIVED | FILE_HIDDEN | FILE_READONLY},
|
||||
{"ARCHSYST",
|
||||
"This file has the archived attribute set.\n"
|
||||
"This file has the system attribute set.\n",
|
||||
"File with archived, system attributes",
|
||||
FILE_ARCHIVED | FILE_SYSTEM},
|
||||
{"ARSYSRDY",
|
||||
"This file has the archived attribute set.\n"
|
||||
"This file has the system attribute set.\n"
|
||||
"This file has the read-only attribute set.\n",
|
||||
"File with archived, system, read-only attributes",
|
||||
FILE_ARCHIVED | FILE_SYSTEM | FILE_READONLY},
|
||||
{"ARCSYSHD",
|
||||
"This file has the archived attribute set.\n"
|
||||
"This file has the system attribute set.\n"
|
||||
"This file has the hidden attribute set.\n",
|
||||
"File with archived, system, hidden attributes",
|
||||
FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN},
|
||||
{"ARSYHDRD",
|
||||
"This file has the archived attribute set.\n"
|
||||
"This file has the system attribute set.\n"
|
||||
"This file has the hidden attribute set.\n"
|
||||
"This file has the read-only attribute set.\n",
|
||||
"File with all (archived, system, hidden, read-only) attributes",
|
||||
FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN | FILE_READONLY},
|
||||
};
|
||||
|
||||
#endif // SETTER_SRC_OS2_ATTR_H_
|
||||
|
||||
#endif
|
||||
@@ -27,9 +27,19 @@ Contains 16-bit OS/2 definitions
|
||||
Copyright (C) 2011-2021 Natalia Portillo
|
||||
*****************************************************************************/
|
||||
|
||||
#if(defined(__OS2__) || defined(__os2__)) && (defined(__I86__) || defined(__i86__) || defined(_M_I86))
|
||||
#ifndef AARU_FSTESTER_SETTER_OS2_16_H
|
||||
#define AARU_FSTESTER_SETTER_OS2_16_H
|
||||
#if(defined(__OS2__) || defined(__os2__))
|
||||
#ifndef AARU_FSTESTER_SETTER_OS2_H
|
||||
#define AARU_FSTESTER_SETTER_OS2_H
|
||||
|
||||
#include <os2.h>
|
||||
|
||||
#if(defined(__I86__) || defined(__i86__) || defined(_M_I86)) // 16 bit
|
||||
|
||||
#ifndef APIRET
|
||||
#define APIRET USHORT
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* Information level types (defins method of query) */
|
||||
#define FSAIL_QUERYNAME 1 /* Return data for a Drive or Device */
|
||||
@@ -242,11 +252,17 @@ unsigned char IconEA[3516] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00};
|
||||
|
||||
const char* archivedAttributeText = "This file has the archived attribute set.\n";
|
||||
const char* systemAttributeText = "This file has the system attribute set.\n";
|
||||
const char* hiddenAttributeText = "This file has the hidden attribute set.\n";
|
||||
const char* readonlyAttributeText = "This file has the read-only attribute set.\n";
|
||||
const char* noAttributeText = "This file has no attribute set.\n";
|
||||
#if(defined(__I86__) || defined(__i86__) || defined(_M_I86)) // 16 bit
|
||||
|
||||
#define __os2_chdir(path) DosChDir(path, 0)
|
||||
#define __os2_mkdir(path) DosMkDir(path, 0)
|
||||
|
||||
#else // 32 bit
|
||||
|
||||
#define __os2_chdir(path) DosSetCurrentDir(path)
|
||||
#define __os2_mkdir(path) DosCreateDir(path, NULL)
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user