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
typedef struct  WIN32_FIND_DATAW
69
{
70
  DWORD dwFileAttributes;
71
  FILETIME ftCreationTime;
72
  FILETIME ftLastAccessTime;
73
  FILETIME ftLastWriteTime;
74
  DWORD    nFileSizeHigh;
75
  DWORD    nFileSizeLow;
76
  DWORD    dwReserved0;
77
  DWORD    dwReserved1;
78
  WORD cFileName[ 130 /* 260 */ ];        /* Correct values are 260 & 14, but as Unicode */
79
  WORD cAlternateFileName[ 7 /* 14 */ ];  /* is unsupported, make size same as Ansi one  */
80
} WIN32_FIND_DATAW;
81
 
82
#define WIN32_FIND_DATA WIN32_FIND_DATAA
83
 
84
typedef struct FFDTA  /* same format as a ffblk struct */
85
{
86
  BYTE reserved[21]; /* dos positioning info */
87
  BYTE ff_attrib;    /* file attributes */
88
  WORD ff_ftime;     /* time when file created/modified */
89
  WORD ff_fdate;     /* date when file created/modified */
90
  DWORD ff_fsize;    /* low word followed by high word */
91
  BYTE ff_name[13];  /* file name, not space padded, period, '\0' terminated, wildcards replaced */
92
} FFDTA;
93
 
94
 
95
#define FINDFILELFN 1
96
#define FINDFILEOLD 0
97
 
98
typedef union FHND  /* Stores either a handle (LFN) or FFDTA (oldstyle) */
99
{
2028 mateusz.vi 100
  WORD handle;
101
  FFDTA *ffdtaptr;
2019 mateusz.vi 102
} FHND;
103
 
104
typedef struct FindFileStruct
105
{
106
  short flag;        /* indicates whether this is for the old or new style find file & thus contents */
107
  FHND fhnd;         /* The data stored */
108
} FindFileStruct;
109
 
110
typedef FindFileStruct *HANDLE;
111
 
112
#define STDCALL
113
 
114
HANDLE STDCALL FindFirstFileA(const char *pathname, WIN32_FIND_DATAA *findData);
115
int STDCALL FindNextFileA(HANDLE hnd, WIN32_FIND_DATAA *findData);
116
void STDCALL FindClose(HANDLE hnd);
117
 
118
#define FindFirstFile FindFirstFileA
119
#define FindNextFile FindNextFileA
120
 
121
DWORD GetFileAttributes(const char *pathname);
122
 
123
/* Only the 1st 4 arguments are used and returns zero on error */
124
int GetVolumeInformation(char *lpRootPathName,char *lpVolumeNameBuffer,
125
  DWORD nVolumeNameSize, DWORD *lpVolumeSerialNumber,
126
  DWORD *lpMaximumComponentLength, DWORD *lpFileSystemFlags,
127
  char *lpFileSystemNameBuffer, DWORD nFileSystemNameSize);
128
 
129
 
2028 mateusz.vi 130
/* If this variable is nonzero then will 1st attempt LFN findfirst
2019 mateusz.vi 131
 * (findfirst calls sets flag, so findnext/findclose know proper method to continue)
132
 * else if 0 then only attempt old 0x4E findfirst.
133
 * This is mostly a debugging tool, may be useful during runtime.
134
 * Default is LFN_ENABLE.
135
 */
136
#define LFN_ENABLE 1
137
#define LFN_DISABLE 0
138
extern int LFN_Enable_Flag;
139
 
140
#endif