Subversion Repositories SvarDOS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2019 mateusz.vi 1
/****************************************************************************
2
 
2028 mateusz.vi 3
  Win32 File compatibility for DOS.
2019 mateusz.vi 4
  [This version does support LFNs, if available.]
5
 
6
  Written by: Kenneth J. Davis
7
  Date:       August, 2000
8
  Contact:    jeremyd@computer.org
9
 
10
 
11
Copyright (c): Public Domain [United States Definition]
12
 
13
Permission is hereby granted, free of charge, to any person obtaining a copy
14
of this software and associated documentation files (the "Software"), to deal
15
in the Software without restriction, including without limitation the rights
16
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
copies of the Software, and to permit persons to whom the Software is
18
furnished to do so, subject to the following conditions:
19
 
20
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23
NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR AUTHORS BE
24
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
25
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
26
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27
DEALINGS IN THE SOFTWARE.
28
 
29
****************************************************************************/
30
 
31
#ifndef W32FDOS_H
32
#define W32FDOS_H
33
 
34
#define INVALID_HANDLE_VALUE ((HANDLE)-1)
35
 
36
#define FILE_ATTRIBUTE_READONLY  0x0001
37
#define FILE_ATTRIBUTE_HIDDEN    0x0002
38
#define FILE_ATTRIBUTE_SYSTEM    0x0004
39
#define FILE_ATTRIBUTE_LABEL     0x0008
40
#define FILE_ATTRIBUTE_DIRECTORY 0x0010
41
#define FILE_ATTRIBUTE_ARCHIVE   0x0020
42
 
43
typedef short BOOL;
44
typedef unsigned char BYTE;
45
typedef unsigned short WORD;
46
typedef unsigned long DWORD;
47
 
48
typedef struct FILETIME   /* should correspond to a quad word */
2028 mateusz.vi 49
{
2019 mateusz.vi 50
  WORD ldw[2];  /* LowDoubleWord  */
51
  DWORD hdw;    /* HighDoubleWord */
52
} FILETIME;
53
 
54
typedef struct  WIN32_FIND_DATAA
55
{
56
  DWORD dwFileAttributes;
57
  FILETIME ftCreationTime;
58
  FILETIME ftLastAccessTime;
59
  FILETIME ftLastWriteTime;
60
  DWORD    nFileSizeHigh;
61
  DWORD    nFileSizeLow;
62
  DWORD    dwReserved0;
63
  DWORD    dwReserved1;
64
  char cFileName[ 260 ];
65
  char cAlternateFileName[ 14 ];
66
} WIN32_FIND_DATAA;
67
 
68
 
69
#define WIN32_FIND_DATA WIN32_FIND_DATAA
70
 
71
typedef struct FFDTA  /* same format as a ffblk struct */
72
{
73
  BYTE reserved[21]; /* dos positioning info */
74
  BYTE ff_attrib;    /* file attributes */
75
  WORD ff_ftime;     /* time when file created/modified */
76
  WORD ff_fdate;     /* date when file created/modified */
77
  DWORD ff_fsize;    /* low word followed by high word */
78
  BYTE ff_name[13];  /* file name, not space padded, period, '\0' terminated, wildcards replaced */
79
} FFDTA;
80
 
81
 
82
#define FINDFILELFN 1
83
#define FINDFILEOLD 0
84
 
85
typedef union FHND  /* Stores either a handle (LFN) or FFDTA (oldstyle) */
86
{
2028 mateusz.vi 87
  WORD handle;
88
  FFDTA *ffdtaptr;
2019 mateusz.vi 89
} FHND;
90
 
91
typedef struct FindFileStruct
92
{
93
  short flag;        /* indicates whether this is for the old or new style find file & thus contents */
94
  FHND fhnd;         /* The data stored */
95
} FindFileStruct;
96
 
97
typedef FindFileStruct *HANDLE;
98
 
99
#define STDCALL
100
 
101
HANDLE STDCALL FindFirstFileA(const char *pathname, WIN32_FIND_DATAA *findData);
102
int STDCALL FindNextFileA(HANDLE hnd, WIN32_FIND_DATAA *findData);
103
void STDCALL FindClose(HANDLE hnd);
104
 
105
#define FindFirstFile FindFirstFileA
106
#define FindNextFile FindNextFileA
107
 
108
DWORD GetFileAttributes(const char *pathname);
109
 
110
/* Only the 1st 4 arguments are used and returns zero on error */
111
int GetVolumeInformation(char *lpRootPathName,char *lpVolumeNameBuffer,
112
  DWORD nVolumeNameSize, DWORD *lpVolumeSerialNumber,
113
  DWORD *lpMaximumComponentLength, DWORD *lpFileSystemFlags,
114
  char *lpFileSystemNameBuffer, DWORD nFileSystemNameSize);
115
 
116
 
2028 mateusz.vi 117
/* If this variable is nonzero then will 1st attempt LFN findfirst
2019 mateusz.vi 118
 * (findfirst calls sets flag, so findnext/findclose know proper method to continue)
119
 * else if 0 then only attempt old 0x4E findfirst.
120
 * This is mostly a debugging tool, may be useful during runtime.
121
 * Default is LFN_ENABLE.
122
 */
123
#define LFN_ENABLE 1
124
#define LFN_DISABLE 0
125
extern int LFN_Enable_Flag;
126
 
127
#endif