| 1 | /* $Id: fileio.cpp,v 1.1 1999-09-15 23:32:54 sandervl Exp $ */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | *
|
|---|
| 5 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 6 | *
|
|---|
| 7 | */
|
|---|
| 8 | /*
|
|---|
| 9 | * Win32 File IO API functions for OS/2
|
|---|
| 10 | *
|
|---|
| 11 | * Copyright 1998 Sander van Leeuwen
|
|---|
| 12 | * Copyright 1998 Patrick Haller
|
|---|
| 13 | *
|
|---|
| 14 | */
|
|---|
| 15 | #include <os2win.h>
|
|---|
| 16 | #include <stdlib.h>
|
|---|
| 17 | #include <string.h>
|
|---|
| 18 | #include "unicode.h"
|
|---|
| 19 | #include <heapstring.h>
|
|---|
| 20 | #include "handlemanager.h"
|
|---|
| 21 | #include "devio.h"
|
|---|
| 22 |
|
|---|
| 23 | //******************************************************************************
|
|---|
| 24 | //******************************************************************************
|
|---|
| 25 | HFILE WIN32API CreateFileA(LPCSTR lpszName,
|
|---|
| 26 | DWORD fdwAccess,
|
|---|
| 27 | DWORD fdwShareMode,
|
|---|
| 28 | LPSECURITY_ATTRIBUTES lpsa,
|
|---|
| 29 | DWORD fdwCreate,
|
|---|
| 30 | DWORD fdwAttrsAndFlags,
|
|---|
| 31 | HANDLE hTemplateFile)
|
|---|
| 32 | {
|
|---|
| 33 | HANDLE rc;
|
|---|
| 34 |
|
|---|
| 35 | dprintf(("KERNEL32: CreateFileA(%s,%08xh,%08xh,%08xh,%08xh,%08xh,%08xh)\n",
|
|---|
| 36 | lpszName,
|
|---|
| 37 | fdwAccess,
|
|---|
| 38 | fdwShareMode,
|
|---|
| 39 | lpsa,
|
|---|
| 40 | fdwCreate,
|
|---|
| 41 | fdwAttrsAndFlags,
|
|---|
| 42 | hTemplateFile));
|
|---|
| 43 |
|
|---|
| 44 | rc = HMCreateFile(lpszName,
|
|---|
| 45 | fdwAccess,
|
|---|
| 46 | fdwShareMode,
|
|---|
| 47 | lpsa,
|
|---|
| 48 | fdwCreate,
|
|---|
| 49 | fdwAttrsAndFlags,
|
|---|
| 50 | hTemplateFile);
|
|---|
| 51 |
|
|---|
| 52 | return(rc);
|
|---|
| 53 | }
|
|---|
| 54 | //******************************************************************************
|
|---|
| 55 | //******************************************************************************
|
|---|
| 56 | HFILE WIN32API CreateFileW(LPCWSTR arg1,
|
|---|
| 57 | DWORD arg2,
|
|---|
| 58 | DWORD arg3,
|
|---|
| 59 | PSECURITY_ATTRIBUTES arg4,
|
|---|
| 60 | DWORD arg5,
|
|---|
| 61 | DWORD arg6,
|
|---|
| 62 | HANDLE arg7)
|
|---|
| 63 | {
|
|---|
| 64 | HANDLE rc;
|
|---|
| 65 | char *astring;
|
|---|
| 66 |
|
|---|
| 67 | dprintf(("KERNEL32: CreateFileW"));
|
|---|
| 68 | astring = UnicodeToAsciiString((LPWSTR)arg1);
|
|---|
| 69 | rc = CreateFileA(astring, arg2, arg3, arg4, arg5, arg6, arg7);
|
|---|
| 70 | FreeAsciiString(astring);
|
|---|
| 71 | return(rc);
|
|---|
| 72 | }
|
|---|
| 73 | //******************************************************************************
|
|---|
| 74 | //******************************************************************************
|
|---|
| 75 | HANDLE WIN32API FindFirstFileA(LPCSTR arg1, WIN32_FIND_DATAA * arg2)
|
|---|
| 76 | {
|
|---|
| 77 | dprintf(("KERNEL32: FindFirstFile(%s,%08xh)\n",
|
|---|
| 78 | arg1,
|
|---|
| 79 | arg2));
|
|---|
| 80 |
|
|---|
| 81 | return O32_FindFirstFile(arg1, arg2);
|
|---|
| 82 | }
|
|---|
| 83 | //******************************************************************************
|
|---|
| 84 | //******************************************************************************
|
|---|
| 85 | HANDLE WIN32API FindFirstFileW(LPCWSTR arg1, WIN32_FIND_DATAW * arg2)
|
|---|
| 86 | {
|
|---|
| 87 | HANDLE rc;
|
|---|
| 88 | char *astring;
|
|---|
| 89 | WIN32_FIND_DATAA wfda;
|
|---|
| 90 |
|
|---|
| 91 | dprintf(("KERNEL32: FindFirstFileW(%08xh, %08xh)",
|
|---|
| 92 | arg1,
|
|---|
| 93 | arg2));
|
|---|
| 94 |
|
|---|
| 95 | astring = UnicodeToAsciiString((LPWSTR)arg1);
|
|---|
| 96 | rc = FindFirstFileA(astring, &wfda);
|
|---|
| 97 |
|
|---|
| 98 | // convert back the result structure
|
|---|
| 99 | memcpy(arg2,
|
|---|
| 100 | &wfda,
|
|---|
| 101 | sizeof(WIN32_FIND_DATAA));
|
|---|
| 102 |
|
|---|
| 103 | lstrcpynAtoW (arg2->cFileName,
|
|---|
| 104 | wfda.cFileName,
|
|---|
| 105 | sizeof(wfda.cFileName));
|
|---|
| 106 |
|
|---|
| 107 | lstrcpynAtoW (arg2->cAlternateFileName,
|
|---|
| 108 | wfda.cAlternateFileName,
|
|---|
| 109 | sizeof(wfda.cAlternateFileName));
|
|---|
| 110 |
|
|---|
| 111 | FreeAsciiString(astring);
|
|---|
| 112 | return(rc);
|
|---|
| 113 | }
|
|---|
| 114 | //******************************************************************************
|
|---|
| 115 | //******************************************************************************
|
|---|
| 116 | BOOL WIN32API FindNextFileA(HANDLE arg1, WIN32_FIND_DATAA * arg2)
|
|---|
| 117 | {
|
|---|
| 118 | dprintf(("KERNEL32: FindNextFile"));
|
|---|
| 119 | return O32_FindNextFile(arg1, arg2);
|
|---|
| 120 | }
|
|---|
| 121 | //******************************************************************************
|
|---|
| 122 | //TODO: convert string in WIN32_FIND_DATAW * structure
|
|---|
| 123 | //******************************************************************************
|
|---|
| 124 | BOOL WIN32API FindNextFileW(HANDLE arg1, WIN32_FIND_DATAW * arg2)
|
|---|
| 125 | {
|
|---|
| 126 | WIN32_FIND_DATAA wfda;
|
|---|
| 127 | BOOL rc;
|
|---|
| 128 |
|
|---|
| 129 | dprintf(("KERNEL32: FindNextFileW(%08xh, %08xh)\n",
|
|---|
| 130 | arg1,
|
|---|
| 131 | arg2));
|
|---|
| 132 |
|
|---|
| 133 | rc = FindNextFileA(arg1, &wfda);
|
|---|
| 134 |
|
|---|
| 135 | // convert back the result structure
|
|---|
| 136 | memcpy(arg2,
|
|---|
| 137 | &wfda,
|
|---|
| 138 | sizeof(WIN32_FIND_DATAA));
|
|---|
| 139 |
|
|---|
| 140 | lstrcpynAtoW (arg2->cFileName,
|
|---|
| 141 | wfda.cFileName,
|
|---|
| 142 | sizeof(wfda.cFileName));
|
|---|
| 143 |
|
|---|
| 144 | lstrcpynAtoW (arg2->cAlternateFileName,
|
|---|
| 145 | wfda.cAlternateFileName,
|
|---|
| 146 | sizeof(wfda.cAlternateFileName));
|
|---|
| 147 |
|
|---|
| 148 | return rc;
|
|---|
| 149 | }
|
|---|
| 150 | //******************************************************************************
|
|---|
| 151 | //******************************************************************************
|
|---|
| 152 | BOOL WIN32API FindClose(HANDLE arg1)
|
|---|
| 153 | {
|
|---|
| 154 | dprintf(("KERNEL32: FindClose\n"));
|
|---|
| 155 | return O32_FindClose(arg1);
|
|---|
| 156 | }
|
|---|
| 157 | //******************************************************************************
|
|---|
| 158 | //******************************************************************************
|
|---|
| 159 | DWORD WIN32API GetFileType(HANDLE hFile)
|
|---|
| 160 | {
|
|---|
| 161 | dprintf(("KERNEL32: GetFileType(%08xh)\n",
|
|---|
| 162 | hFile));
|
|---|
| 163 |
|
|---|
| 164 | return(HMGetFileType(hFile));
|
|---|
| 165 | }
|
|---|
| 166 | //******************************************************************************
|
|---|
| 167 | //******************************************************************************
|
|---|
| 168 | DWORD WIN32API GetFileInformationByHandle(HANDLE arg1,
|
|---|
| 169 | BY_HANDLE_FILE_INFORMATION *arg2)
|
|---|
| 170 | {
|
|---|
| 171 | dprintf(("KERNEL32: GetFIleInformationByHandle(%08xh,%0xh)\n",
|
|---|
| 172 | arg1,
|
|---|
| 173 | arg2));
|
|---|
| 174 |
|
|---|
| 175 | return(HMGetFileInformationByHandle(arg1,arg2));
|
|---|
| 176 | }
|
|---|
| 177 | //******************************************************************************
|
|---|
| 178 | //******************************************************************************
|
|---|
| 179 | BOOL WIN32API SetEndOfFile( HANDLE arg1)
|
|---|
| 180 | {
|
|---|
| 181 | dprintf(("KERNEL32: SetEndOfFile(%08xh)\n",
|
|---|
| 182 | arg1));
|
|---|
| 183 |
|
|---|
| 184 | return HMSetEndOfFile(arg1);
|
|---|
| 185 | }
|
|---|
| 186 | //******************************************************************************
|
|---|
| 187 | //******************************************************************************
|
|---|
| 188 | BOOL WIN32API SetFileTime(HANDLE arg1,
|
|---|
| 189 | const FILETIME *arg2,
|
|---|
| 190 | const FILETIME *arg3,
|
|---|
| 191 | const FILETIME *arg4)
|
|---|
| 192 | {
|
|---|
| 193 | dprintf(("KERNEL32: SetFileTime(%08xh,%08xh,%08xh,%08xh)\n",
|
|---|
| 194 | arg1,
|
|---|
| 195 | arg2,
|
|---|
| 196 | arg3,
|
|---|
| 197 | arg4));
|
|---|
| 198 |
|
|---|
| 199 | return HMSetFileTime(arg1,
|
|---|
| 200 | arg2,
|
|---|
| 201 | arg3,
|
|---|
| 202 | arg4);
|
|---|
| 203 | }
|
|---|
| 204 | //******************************************************************************
|
|---|
| 205 | //******************************************************************************
|
|---|
| 206 | INT WIN32API CompareFileTime( FILETIME * arg1, FILETIME * arg2)
|
|---|
| 207 | {
|
|---|
| 208 | dprintf(("KERNEL32: CompareFileTime\n"));
|
|---|
| 209 | return O32_CompareFileTime(arg1, arg2);
|
|---|
| 210 | }
|
|---|
| 211 | //******************************************************************************
|
|---|
| 212 | //******************************************************************************
|
|---|
| 213 | BOOL WIN32API CopyFileA(LPCSTR arg1, LPCSTR arg2, BOOL arg3)
|
|---|
| 214 | {
|
|---|
| 215 | dprintf(("KERNEL32: CopyFile %s %s\n", arg1, arg2));
|
|---|
| 216 | return O32_CopyFile(arg1, arg2, arg3);
|
|---|
| 217 | }
|
|---|
| 218 | //******************************************************************************
|
|---|
| 219 | //SvL: 24-6-'97 - Added
|
|---|
| 220 | //******************************************************************************
|
|---|
| 221 | BOOL WIN32API CopyFileW(LPCWSTR arg1, LPCWSTR arg2, BOOL arg3)
|
|---|
| 222 | {
|
|---|
| 223 | BOOL rc;
|
|---|
| 224 | char *astring1, *astring2;
|
|---|
| 225 |
|
|---|
| 226 | astring1 = UnicodeToAsciiString((LPWSTR)arg1);
|
|---|
| 227 | astring2 = UnicodeToAsciiString((LPWSTR)arg2);
|
|---|
| 228 | dprintf(("KERNEL32: CopyFileW\n"));
|
|---|
| 229 | rc = O32_CopyFile(astring1, astring2, arg3);
|
|---|
| 230 | FreeAsciiString(astring2);
|
|---|
| 231 | FreeAsciiString(astring1);
|
|---|
| 232 | return(rc);
|
|---|
| 233 | }
|
|---|
| 234 | //******************************************************************************
|
|---|
| 235 | //******************************************************************************
|
|---|
| 236 | DWORD WIN32API GetFileSize( HANDLE arg1, PDWORD arg2)
|
|---|
| 237 | {
|
|---|
| 238 | dprintf(("KERNEL32: GetFileSize (%08xh, %08xh)\n",
|
|---|
| 239 | arg1,
|
|---|
| 240 | arg2));
|
|---|
| 241 |
|
|---|
| 242 | return HMGetFileSize(arg1,
|
|---|
| 243 | arg2);
|
|---|
| 244 | }
|
|---|
| 245 | //******************************************************************************
|
|---|
| 246 | //******************************************************************************
|
|---|
| 247 | BOOL WIN32API DeleteFileA(LPCSTR arg1)
|
|---|
| 248 | {
|
|---|
| 249 | dprintf(("KERNEL32: DeleteFile %s\n", arg1));
|
|---|
| 250 | return O32_DeleteFile(arg1);
|
|---|
| 251 | }
|
|---|
| 252 | //******************************************************************************
|
|---|
| 253 | //******************************************************************************
|
|---|
| 254 | BOOL WIN32API DeleteFileW(LPCWSTR arg1)
|
|---|
| 255 | {
|
|---|
| 256 | BOOL rc;
|
|---|
| 257 | char *astring;
|
|---|
| 258 |
|
|---|
| 259 | dprintf(("KERNEL32: DeleteFileW\n"));
|
|---|
| 260 | astring = UnicodeToAsciiString((LPWSTR)arg1);
|
|---|
| 261 | rc = O32_DeleteFile(astring);
|
|---|
| 262 | FreeAsciiString(astring);
|
|---|
| 263 | return(rc);
|
|---|
| 264 | }
|
|---|
| 265 | //******************************************************************************
|
|---|
| 266 | //******************************************************************************
|
|---|
| 267 | UINT WIN32API GetTempFileNameA(LPCSTR arg1, LPCSTR arg2, UINT arg3, LPSTR arg4)
|
|---|
| 268 | {
|
|---|
| 269 | dprintf(("KERNEL32: GetTempFileName"));
|
|---|
| 270 | return O32_GetTempFileName(arg1, arg2, arg3, arg4);
|
|---|
| 271 | }
|
|---|
| 272 | //******************************************************************************
|
|---|
| 273 | //******************************************************************************
|
|---|
| 274 | UINT WIN32API GetTempFileNameW(LPCWSTR lpPathName, LPCWSTR lpPrefixString,
|
|---|
| 275 | UINT uUnique, LPWSTR lpTempFileName)
|
|---|
| 276 | {
|
|---|
| 277 | char *asciipath, *asciiprefix;
|
|---|
| 278 | char *asciitemp = (char *)malloc(MAX_PATH+1);
|
|---|
| 279 | UINT rc;
|
|---|
| 280 |
|
|---|
| 281 | dprintf(("KERNEL32: GetTempFileNameW"));
|
|---|
| 282 | asciipath = UnicodeToAsciiString((LPWSTR)lpPathName);
|
|---|
| 283 | asciiprefix = UnicodeToAsciiString((LPWSTR)lpPrefixString);
|
|---|
| 284 | rc = O32_GetTempFileName(asciipath, asciiprefix, uUnique, asciitemp);
|
|---|
| 285 | if(rc) AsciiToUnicode(asciitemp, lpTempFileName);
|
|---|
| 286 | FreeAsciiString(asciiprefix);
|
|---|
| 287 | FreeAsciiString(asciipath);
|
|---|
| 288 | free(asciitemp);
|
|---|
| 289 | return(rc);
|
|---|
| 290 | }
|
|---|
| 291 | //******************************************************************************
|
|---|
| 292 | //******************************************************************************
|
|---|
| 293 | UINT WIN32API GetTempPathA(UINT arg1, LPSTR arg2)
|
|---|
| 294 | {
|
|---|
| 295 | dprintf(("KERNEL32: GetTempPath\n"));
|
|---|
| 296 | return O32_GetTempPath(arg1, arg2);
|
|---|
| 297 | }
|
|---|
| 298 | //******************************************************************************
|
|---|
| 299 | //******************************************************************************
|
|---|
| 300 | UINT WIN32API GetTempPathW(UINT nBufferLength, LPWSTR lpBuffer)
|
|---|
| 301 | {
|
|---|
| 302 | char *asciibuffer = (char *)malloc(nBufferLength+1);
|
|---|
| 303 | DWORD rc;
|
|---|
| 304 |
|
|---|
| 305 | dprintf(("KERNEL32: GetTempPathW\n"));
|
|---|
| 306 | rc = O32_GetTempPath(nBufferLength, asciibuffer);
|
|---|
| 307 | if(rc) AsciiToUnicode(asciibuffer, lpBuffer);
|
|---|
| 308 | free(asciibuffer);
|
|---|
| 309 | return(rc);
|
|---|
| 310 | }
|
|---|
| 311 | //******************************************************************************
|
|---|
| 312 | //******************************************************************************
|
|---|
| 313 | BOOL WIN32API ReadFile(HANDLE arg1,
|
|---|
| 314 | PVOID arg2,
|
|---|
| 315 | DWORD arg3,
|
|---|
| 316 | PDWORD arg4,
|
|---|
| 317 | LPOVERLAPPED arg5)
|
|---|
| 318 | {
|
|---|
| 319 | BOOL rc;
|
|---|
| 320 |
|
|---|
| 321 | rc = HMReadFile(arg1,
|
|---|
| 322 | arg2,
|
|---|
| 323 | arg3,
|
|---|
| 324 | arg4,
|
|---|
| 325 | arg5);
|
|---|
| 326 |
|
|---|
| 327 | dprintf(("KERNEL32: ReadFile %X %d bytes returned %d\n",
|
|---|
| 328 | arg1,
|
|---|
| 329 | arg3,
|
|---|
| 330 | rc));
|
|---|
| 331 |
|
|---|
| 332 | return(rc);
|
|---|
| 333 | }
|
|---|
| 334 | //******************************************************************************
|
|---|
| 335 | //******************************************************************************
|
|---|
| 336 | DWORD WIN32API SetFilePointer(HANDLE hFile,
|
|---|
| 337 | LONG lDistanceToMove,
|
|---|
| 338 | PLONG lpDistanceToMoveHigh,
|
|---|
| 339 | DWORD dwMoveMethod)
|
|---|
| 340 | {
|
|---|
| 341 | dprintf(("KERNEL32: SetFilePointer(%08xh,%08xh,%08xh,%08xh)\n",
|
|---|
| 342 | hFile,
|
|---|
| 343 | lDistanceToMove,
|
|---|
| 344 | lpDistanceToMoveHigh,
|
|---|
| 345 | dwMoveMethod));
|
|---|
| 346 |
|
|---|
| 347 | return(HMSetFilePointer(hFile,
|
|---|
| 348 | lDistanceToMove,
|
|---|
| 349 | lpDistanceToMoveHigh,
|
|---|
| 350 | dwMoveMethod));
|
|---|
| 351 | }
|
|---|
| 352 | //******************************************************************************
|
|---|
| 353 | //******************************************************************************
|
|---|
| 354 | BOOL WIN32API WriteFile(HANDLE hFile,
|
|---|
| 355 | LPCVOID buffer,
|
|---|
| 356 | DWORD nrbytes,
|
|---|
| 357 | LPDWORD nrbyteswritten,
|
|---|
| 358 | LPOVERLAPPED lpOverlapped)
|
|---|
| 359 | {
|
|---|
| 360 | dprintf(("KERNEL32: WriteFile(%08xh,%08xh,%08xh,%08xh,%08xh)\n",
|
|---|
| 361 | hFile,
|
|---|
| 362 | buffer,
|
|---|
| 363 | nrbytes,
|
|---|
| 364 | nrbyteswritten,
|
|---|
| 365 | lpOverlapped));
|
|---|
| 366 |
|
|---|
| 367 | return (HMWriteFile(hFile,
|
|---|
| 368 | buffer,
|
|---|
| 369 | nrbytes,
|
|---|
| 370 | nrbyteswritten,
|
|---|
| 371 | lpOverlapped));
|
|---|
| 372 | }
|
|---|
| 373 | //******************************************************************************
|
|---|
| 374 | //******************************************************************************
|
|---|
| 375 | DWORD WIN32API SearchPathA( LPCSTR arg1, LPCSTR arg2, LPCSTR arg3, DWORD arg4, LPSTR arg5, LPSTR * arg6)
|
|---|
| 376 | {
|
|---|
| 377 | dprintf(("KERNEL32: SearchPathA\n"));
|
|---|
| 378 | return O32_SearchPath(arg1, arg2, arg3, arg4, arg5, arg6);
|
|---|
| 379 | }
|
|---|
| 380 | //******************************************************************************
|
|---|
| 381 | //******************************************************************************
|
|---|
| 382 | DWORD WIN32API SearchPathW(LPCWSTR lpPath, LPCWSTR lpFileName, LPCWSTR lpExtension,
|
|---|
| 383 | DWORD nBufferLength, LPWSTR lpBuffer, LPWSTR *lpFilePart)
|
|---|
| 384 | {
|
|---|
| 385 | char *asciipath, *asciifile, *asciiext, *asciibuffer, *asciipart;
|
|---|
| 386 | DWORD rc;
|
|---|
| 387 |
|
|---|
| 388 | dprintf(("KERNEL32: SearchPathW"));
|
|---|
| 389 | asciibuffer = (char *)malloc(nBufferLength+1);
|
|---|
| 390 | asciipath = UnicodeToAsciiString((LPWSTR)lpPath);
|
|---|
| 391 | asciifile = UnicodeToAsciiString((LPWSTR)lpFileName);
|
|---|
| 392 | asciiext = UnicodeToAsciiString((LPWSTR)lpFileName);
|
|---|
| 393 | rc = O32_SearchPath(asciipath, asciifile, asciiext, nBufferLength, asciibuffer, &asciipart);
|
|---|
| 394 |
|
|---|
| 395 | if(rc) {
|
|---|
| 396 | AsciiToUnicode(asciibuffer, lpBuffer);
|
|---|
| 397 | *lpFilePart = lpBuffer + ((int)asciipart - (int)asciibuffer);
|
|---|
| 398 | }
|
|---|
| 399 | FreeAsciiString(asciiext);
|
|---|
| 400 | FreeAsciiString(asciifile);
|
|---|
| 401 | FreeAsciiString(asciipath);
|
|---|
| 402 | free(asciibuffer);
|
|---|
| 403 | return(rc);
|
|---|
| 404 | }
|
|---|
| 405 | //******************************************************************************
|
|---|
| 406 | //******************************************************************************
|
|---|
| 407 | DWORD WIN32API GetFileAttributesA(LPCSTR lpszFileName)
|
|---|
| 408 | {
|
|---|
| 409 | DWORD rc, error;
|
|---|
| 410 |
|
|---|
| 411 | rc = O32_GetFileAttributes((LPSTR)lpszFileName);
|
|---|
| 412 | #if 0 // need more tests, maybe there is also a better way to hide simulated b:
|
|---|
| 413 | if(rc == -1 && lpszFileName != NULL && !strnicmp(lpszFileName, "B:", 2))
|
|---|
| 414 | {
|
|---|
| 415 | error = GetLastError();
|
|---|
| 416 | if(error = ERROR_DISK_CHANGE)
|
|---|
| 417 | SetLastError(ERROR_NOT_READY);
|
|---|
| 418 | else
|
|---|
| 419 | SetLastError(error);
|
|---|
| 420 | }
|
|---|
| 421 | #endif
|
|---|
| 422 | dprintf(("KERNEL32: GetFileAttributes of %s returned %d\n", lpszFileName, rc));
|
|---|
| 423 | return(rc);
|
|---|
| 424 | }
|
|---|
| 425 | //******************************************************************************
|
|---|
| 426 | //******************************************************************************
|
|---|
| 427 | DWORD WIN32API GetFileAttributesW(LPCWSTR arg1)
|
|---|
| 428 | {
|
|---|
| 429 | DWORD rc;
|
|---|
| 430 | char *astring;
|
|---|
| 431 |
|
|---|
| 432 | dprintf(("KERNEL32: GetFileAttributesW\n"));
|
|---|
| 433 | astring = UnicodeToAsciiString((LPWSTR)arg1);
|
|---|
| 434 | rc = O32_GetFileAttributes(astring);
|
|---|
| 435 | FreeAsciiString(astring);
|
|---|
| 436 | return(rc);
|
|---|
| 437 | }
|
|---|
| 438 | //******************************************************************************
|
|---|
| 439 | //******************************************************************************
|
|---|
| 440 | BOOL WIN32API SetFileAttributesA(LPCSTR arg1, DWORD arg2)
|
|---|
| 441 | {
|
|---|
| 442 | dprintf(("KERNEL32: SetFileAttributes of %s\n", arg1));
|
|---|
| 443 | return O32_SetFileAttributes(arg1, arg2);
|
|---|
| 444 | }
|
|---|
| 445 | //******************************************************************************
|
|---|
| 446 | //******************************************************************************
|
|---|
| 447 | BOOL WIN32API SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes)
|
|---|
| 448 | {
|
|---|
| 449 | char *asciifile;
|
|---|
| 450 | BOOL rc;
|
|---|
| 451 |
|
|---|
| 452 | dprintf(("KERNEL32: SetFileAttributesW\n"));
|
|---|
| 453 | asciifile = UnicodeToAsciiString((LPWSTR)lpFileName);
|
|---|
| 454 | rc = O32_SetFileAttributes(asciifile, dwFileAttributes);
|
|---|
| 455 | FreeAsciiString(asciifile);
|
|---|
| 456 | return(rc);
|
|---|
| 457 | }
|
|---|
| 458 | //******************************************************************************
|
|---|
| 459 | //******************************************************************************
|
|---|
| 460 | DWORD WIN32API GetFullPathNameA(LPCSTR arg1, DWORD arg2, LPSTR arg3, LPSTR *arg4)
|
|---|
| 461 | {
|
|---|
| 462 | dprintf(("KERNEL32: GetFullPathName %s\n", arg1));
|
|---|
| 463 | return O32_GetFullPathName(arg1, arg2, arg3, arg4);
|
|---|
| 464 | }
|
|---|
| 465 | //******************************************************************************
|
|---|
| 466 | //******************************************************************************
|
|---|
| 467 | DWORD WIN32API GetFullPathNameW(LPCWSTR lpFileName, DWORD nBufferLength,
|
|---|
| 468 | LPWSTR lpBuffer, LPWSTR *lpFilePart)
|
|---|
| 469 | {
|
|---|
| 470 | char *astring, *asciibuffer, *asciipart;
|
|---|
| 471 | DWORD rc;
|
|---|
| 472 |
|
|---|
| 473 | dprintf(("KERNEL32: GetFullPathNameW\n"));
|
|---|
| 474 | asciibuffer = (char *)malloc(nBufferLength+1);
|
|---|
| 475 | astring = UnicodeToAsciiString((LPWSTR)lpFileName);
|
|---|
| 476 |
|
|---|
| 477 | rc = O32_GetFullPathName(astring,
|
|---|
| 478 | nBufferLength,
|
|---|
| 479 | asciibuffer,
|
|---|
| 480 | &asciipart);
|
|---|
| 481 |
|
|---|
| 482 | dprintf(("KERNEL32: GetFullPathNameW %s returns %s\n",
|
|---|
| 483 | astring,
|
|---|
| 484 | asciibuffer));
|
|---|
| 485 |
|
|---|
| 486 | if(rc)
|
|---|
| 487 | AsciiToUnicode(asciibuffer,
|
|---|
| 488 | lpBuffer);
|
|---|
| 489 |
|
|---|
| 490 | *lpFilePart = lpBuffer + ((int)asciipart - (int)asciibuffer);
|
|---|
| 491 |
|
|---|
| 492 | FreeAsciiString(astring);
|
|---|
| 493 | free(asciibuffer);
|
|---|
| 494 | return(rc);
|
|---|
| 495 | }
|
|---|
| 496 | //******************************************************************************
|
|---|
| 497 | //******************************************************************************
|
|---|
| 498 | BOOL WIN32API LockFile(HANDLE arg1,
|
|---|
| 499 | DWORD arg2,
|
|---|
| 500 | DWORD arg3,
|
|---|
| 501 | DWORD arg4,
|
|---|
| 502 | DWORD arg5)
|
|---|
| 503 | {
|
|---|
| 504 | dprintf(("KERNEL32: LockFile (%08xh,%08xh,%08xh,%08xh,%08xh)\n",
|
|---|
| 505 | arg1,
|
|---|
| 506 | arg2,
|
|---|
| 507 | arg3,
|
|---|
| 508 | arg4,
|
|---|
| 509 | arg5));
|
|---|
| 510 |
|
|---|
| 511 | return HMLockFile(arg1,
|
|---|
| 512 | arg2,
|
|---|
| 513 | arg3,
|
|---|
| 514 | arg4,
|
|---|
| 515 | arg5);
|
|---|
| 516 | }
|
|---|
| 517 |
|
|---|
| 518 |
|
|---|
| 519 | /*****************************************************************************
|
|---|
| 520 | * Name : BOOL LockFileEx
|
|---|
| 521 | * Purpose : The LockFileEx function locks a byte range within an open file for shared or exclusive access.
|
|---|
| 522 | * Parameters: HANDLE hFile handle of file to lock
|
|---|
| 523 | * DWORD dwFlags functional behavior modification flags
|
|---|
| 524 | * DWORD dwReserved reserved, must be set to zero
|
|---|
| 525 | * DWORD nNumberOfBytesToLockLow low-order 32 bits of length to lock
|
|---|
| 526 | * DWORD nNumberOfBytesToLockHigh high-order 32 bits of length to lock
|
|---|
| 527 | * LPOVERLAPPED LPOVERLAPPED addr. of structure with lock region start offset
|
|---|
| 528 | * Variables :
|
|---|
| 529 | * Result : TRUE / FALSE
|
|---|
| 530 | * Remark :
|
|---|
| 531 | * Status : UNTESTED STUB
|
|---|
| 532 | *
|
|---|
| 533 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
|---|
| 534 | *****************************************************************************/
|
|---|
| 535 |
|
|---|
| 536 | BOOL WIN32API LockFileEx(HANDLE hFile,
|
|---|
| 537 | DWORD dwFlags,
|
|---|
| 538 | DWORD dwReserved,
|
|---|
| 539 | DWORD nNumberOfBytesToLockLow,
|
|---|
| 540 | DWORD nNumberOfBytesToLockHigh,
|
|---|
| 541 | LPOVERLAPPED lpOverlapped)
|
|---|
| 542 | {
|
|---|
| 543 | dprintf(("Kernel32: LockFileEx(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh)\n",
|
|---|
| 544 | hFile,
|
|---|
| 545 | dwFlags,
|
|---|
| 546 | dwReserved,
|
|---|
| 547 | nNumberOfBytesToLockLow,
|
|---|
| 548 | nNumberOfBytesToLockHigh,
|
|---|
| 549 | lpOverlapped));
|
|---|
| 550 |
|
|---|
| 551 | return(HMLockFile(hFile,
|
|---|
| 552 | lpOverlapped->Offset,
|
|---|
| 553 | lpOverlapped->OffsetHigh,
|
|---|
| 554 | nNumberOfBytesToLockLow,
|
|---|
| 555 | nNumberOfBytesToLockHigh));
|
|---|
| 556 | }
|
|---|
| 557 |
|
|---|
| 558 |
|
|---|
| 559 |
|
|---|
| 560 |
|
|---|
| 561 | //******************************************************************************
|
|---|
| 562 | //******************************************************************************
|
|---|
| 563 | BOOL WIN32API MoveFileA( LPCSTR arg1, LPCSTR arg2)
|
|---|
| 564 | {
|
|---|
| 565 | dprintf(("KERNEL32: MoveFileA\n"));
|
|---|
| 566 | return O32_MoveFile(arg1, arg2);
|
|---|
| 567 | }
|
|---|
| 568 | //******************************************************************************
|
|---|
| 569 | //******************************************************************************
|
|---|
| 570 | BOOL WIN32API MoveFileExA(LPCSTR arg1,
|
|---|
| 571 | LPCSTR arg2,
|
|---|
| 572 | DWORD fdwFlags)
|
|---|
| 573 | {
|
|---|
| 574 | dprintf(("KERNEL32: MoveFileExA %s to %s, not complete!\n", arg1, arg2));
|
|---|
| 575 | return O32_MoveFile(arg1, arg2);
|
|---|
| 576 | }
|
|---|
| 577 | //******************************************************************************
|
|---|
| 578 | //******************************************************************************
|
|---|
| 579 | BOOL WIN32API MoveFileW(LPCWSTR lpSrc, LPCWSTR lpDest)
|
|---|
| 580 | {
|
|---|
| 581 | char *asciisrc, *asciidest;
|
|---|
| 582 | BOOL rc;
|
|---|
| 583 |
|
|---|
| 584 | dprintf(("KERNEL32: MoveFileW\n"));
|
|---|
| 585 | asciisrc = UnicodeToAsciiString((LPWSTR)lpSrc);
|
|---|
| 586 | asciidest = UnicodeToAsciiString((LPWSTR)lpDest);
|
|---|
| 587 | rc = O32_MoveFile(asciisrc, asciidest);
|
|---|
| 588 | FreeAsciiString(asciisrc);
|
|---|
| 589 | FreeAsciiString(asciidest);
|
|---|
| 590 | return(rc);
|
|---|
| 591 | }
|
|---|
| 592 | //******************************************************************************
|
|---|
| 593 | //******************************************************************************
|
|---|
| 594 | BOOL WIN32API MoveFileExW(LPCWSTR arg1,
|
|---|
| 595 | LPCWSTR arg2,
|
|---|
| 596 | DWORD fdwFlags)
|
|---|
| 597 | {
|
|---|
| 598 | dprintf(("KERNEL32: MoveFileExW %s to %s, not complete!\n", arg1, arg2));
|
|---|
| 599 | return MoveFileW(arg1, arg2);
|
|---|
| 600 | }
|
|---|
| 601 | //******************************************************************************
|
|---|
| 602 | /*****************************************************************************
|
|---|
| 603 | * Name : HFILE WIN32API OpenFile
|
|---|
| 604 | * Purpose : forward OpenFile to Open32
|
|---|
| 605 | * Parameters:
|
|---|
| 606 | * Variables :
|
|---|
| 607 | * Result : API returncode
|
|---|
| 608 | * Remark : modified for handle translation support
|
|---|
| 609 | * Status : @@@PH verify if 0 is a valid "invalid handle" :)
|
|---|
| 610 | *
|
|---|
| 611 | * Author : Patrick Haller [Fri, 1998/06/12 02:53]
|
|---|
| 612 | *****************************************************************************/
|
|---|
| 613 |
|
|---|
| 614 | HFILE WIN32API OpenFile(LPCSTR arg1,
|
|---|
| 615 | OFSTRUCT *arg2,
|
|---|
| 616 | UINT arg3)
|
|---|
| 617 | {
|
|---|
| 618 | HFILE hFile;
|
|---|
| 619 |
|
|---|
| 620 | dprintf(("KERNEL32: OpenFile(%s, %08xh, %08xh)\n",
|
|---|
| 621 | arg1,
|
|---|
| 622 | arg2,
|
|---|
| 623 | arg3));
|
|---|
| 624 |
|
|---|
| 625 | hFile = HMOpenFile(arg1, /* call open32 */
|
|---|
| 626 | arg2,
|
|---|
| 627 | arg3);
|
|---|
| 628 |
|
|---|
| 629 | return (hFile);
|
|---|
| 630 | }
|
|---|
| 631 | //******************************************************************************
|
|---|
| 632 | //******************************************************************************
|
|---|
| 633 | BOOL WIN32API UnlockFile(HANDLE arg1,
|
|---|
| 634 | DWORD arg2,
|
|---|
| 635 | DWORD arg3,
|
|---|
| 636 | DWORD arg4,
|
|---|
| 637 | DWORD arg5)
|
|---|
| 638 | {
|
|---|
| 639 | dprintf(("KERNEL32: UnlockFile(%08xh,%08xh,%08xh,%08xh,%08xh)\n",
|
|---|
| 640 | arg1,
|
|---|
| 641 | arg2,
|
|---|
| 642 | arg3,
|
|---|
| 643 | arg4,
|
|---|
| 644 | arg5));
|
|---|
| 645 |
|
|---|
| 646 | return HMUnlockFile(arg1,
|
|---|
| 647 | arg2,
|
|---|
| 648 | arg3,
|
|---|
| 649 | arg4,
|
|---|
| 650 | arg5);
|
|---|
| 651 | }
|
|---|
| 652 |
|
|---|
| 653 |
|
|---|
| 654 | /*****************************************************************************
|
|---|
| 655 | * Name : BOOL UnlockFileEx
|
|---|
| 656 | * Purpose : The UnlockFileEx function unlocks a previously locked byte range in an open file.
|
|---|
| 657 | * Parameters: HANDLE hFile handle of file to lock
|
|---|
| 658 | * DWORD dwReserved reserved, must be set to zero
|
|---|
| 659 | * DWORD nNumberOfBytesToLockLow low-order 32 bits of length to lock
|
|---|
| 660 | * DWORD nNumberOfBytesToLockHigh high-order 32 bits of length to lock
|
|---|
| 661 | * LPOVERLAPPED LPOVERLAPPED addr. of structure with lock region start offset
|
|---|
| 662 | * Variables :
|
|---|
| 663 | * Result : TRUE / FALSE
|
|---|
| 664 | * Remark :
|
|---|
| 665 | * Status : UNTESTED STUB
|
|---|
| 666 | *
|
|---|
| 667 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
|---|
| 668 | *****************************************************************************/
|
|---|
| 669 |
|
|---|
| 670 | BOOL WIN32API UnlockFileEx(HANDLE hFile,
|
|---|
| 671 | DWORD dwReserved,
|
|---|
| 672 | DWORD nNumberOfBytesToLockLow,
|
|---|
| 673 | DWORD nNumberOfBytesToLockHigh,
|
|---|
| 674 | LPOVERLAPPED lpOverlapped)
|
|---|
| 675 | {
|
|---|
| 676 | dprintf(("Kernel32: UnlockFileEx(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh)\n",
|
|---|
| 677 | hFile,
|
|---|
| 678 | dwReserved,
|
|---|
| 679 | nNumberOfBytesToLockLow,
|
|---|
| 680 | nNumberOfBytesToLockHigh,
|
|---|
| 681 | lpOverlapped));
|
|---|
| 682 |
|
|---|
| 683 | return(HMUnlockFile(hFile,
|
|---|
| 684 | lpOverlapped->Offset,
|
|---|
| 685 | lpOverlapped->OffsetHigh,
|
|---|
| 686 | nNumberOfBytesToLockLow,
|
|---|
| 687 | nNumberOfBytesToLockHigh));
|
|---|
| 688 | }
|
|---|
| 689 | //******************************************************************************
|
|---|
| 690 | //******************************************************************************
|
|---|
| 691 | DWORD WIN32API GetShortPathNameA(LPCTSTR lpszLongPath, LPTSTR lpszShortPath,
|
|---|
| 692 | DWORD cchBuffer)
|
|---|
| 693 | {
|
|---|
| 694 | int length;
|
|---|
| 695 |
|
|---|
| 696 | dprintf(("KERNEL32: GetShortPathNameA of %s, just copying it\n", lpszLongPath));
|
|---|
| 697 | length = strlen(lpszLongPath) + 1;
|
|---|
| 698 | if(length > cchBuffer) {
|
|---|
| 699 | *lpszShortPath = 0;
|
|---|
| 700 | return(length);
|
|---|
| 701 | }
|
|---|
| 702 | memcpy(lpszShortPath, lpszLongPath, length);
|
|---|
| 703 | return(length-1);
|
|---|
| 704 | }
|
|---|
| 705 | //******************************************************************************
|
|---|
| 706 | //******************************************************************************
|
|---|
| 707 | DWORD WIN32API GetShortPathNameW(LPCWSTR lpszLongPath, LPWSTR lpszShortPath,
|
|---|
| 708 | DWORD cchBuffer)
|
|---|
| 709 | {
|
|---|
| 710 | int length;
|
|---|
| 711 |
|
|---|
| 712 | dprintf(("KERNEL32: GetShortPathNameW; just copying it\n"));
|
|---|
| 713 | length = UniStrlen((UniChar*)lpszLongPath) + 1;
|
|---|
| 714 | if(length > cchBuffer) {
|
|---|
| 715 | *lpszShortPath = 0;
|
|---|
| 716 | return(length);
|
|---|
| 717 | }
|
|---|
| 718 | memcpy(lpszShortPath, lpszLongPath, length*sizeof(USHORT));
|
|---|
| 719 | return(length-1);
|
|---|
| 720 | }
|
|---|
| 721 | //******************************************************************************
|
|---|
| 722 | //******************************************************************************
|
|---|
| 723 | HANDLE WIN32API FindFirstChangeNotificationA(LPCSTR lpPathName, BOOL bWatchSubtree,
|
|---|
| 724 | DWORD dwNotifyFilter)
|
|---|
| 725 | {
|
|---|
| 726 | dprintf(("KERNEL32: FindFirstChangeNotificationA, Not implemented\n"));
|
|---|
| 727 | return(0);
|
|---|
| 728 | }
|
|---|
| 729 | //******************************************************************************
|
|---|
| 730 | //******************************************************************************
|
|---|
| 731 | BOOL WIN32API FindNextChangeNotification(HANDLE hChange)
|
|---|
| 732 | {
|
|---|
| 733 | dprintf(("KERNEL32: FindNextChangeNotification (%08xh), Not implemented\n",
|
|---|
| 734 | hChange));
|
|---|
| 735 |
|
|---|
| 736 | return(0);
|
|---|
| 737 | }
|
|---|
| 738 | //******************************************************************************
|
|---|
| 739 | //******************************************************************************
|
|---|
| 740 | VOID WIN32API SetFileApisToANSI( VOID ) /*PLF Tue 98-02-10 00:52:22*/
|
|---|
| 741 | {
|
|---|
| 742 | dprintf(("SetFileApisToANSI() stub\n"));
|
|---|
| 743 | }
|
|---|
| 744 |
|
|---|
| 745 | /*****************************************************************************
|
|---|
| 746 | * Name : DWORD GetCompressedFileSizeA
|
|---|
| 747 | * Purpose : The GetCompressedFileSizeA function obtains the compressed
|
|---|
| 748 | * size, in bytes, of a specified file.
|
|---|
| 749 | * Parameters: LPCTSTR lpFileName, // pointer to name of file
|
|---|
| 750 | * LPDWORD lpFileSizeHigh // pointer to DWORD to receive
|
|---|
| 751 | * high-order doubleword of file size
|
|---|
| 752 | * Variables :
|
|---|
| 753 | * Result : size of compressed file
|
|---|
| 754 | * Remark :
|
|---|
| 755 | * Status : UNTESTED
|
|---|
| 756 | *
|
|---|
| 757 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
|---|
| 758 | *****************************************************************************/
|
|---|
| 759 |
|
|---|
| 760 | DWORD WIN32API GetCompressedFileSizeA(LPCTSTR lpFileName,
|
|---|
| 761 | LPDWORD lpFileSizeHigh)
|
|---|
| 762 | {
|
|---|
| 763 | dprintf(("KERNEL32: GetCompressedFileSizeA (%s, %08xh) not implemented.\n",
|
|---|
| 764 | lpFileName,
|
|---|
| 765 | lpFileSizeHigh));
|
|---|
| 766 |
|
|---|
| 767 | /* PH: simply return the standard filesize */
|
|---|
| 768 | return 0;
|
|---|
| 769 | }
|
|---|
| 770 |
|
|---|
| 771 |
|
|---|
| 772 | /*****************************************************************************
|
|---|
| 773 | * Name : DWORD GetCompressedFileSizeW
|
|---|
| 774 | * Purpose : The GetCompressedFileSizeE function obtains the compressed
|
|---|
| 775 | * size, in bytes, of a specified file.
|
|---|
| 776 | * Parameters: LPCWSTR lpFileName, // pointer to name of file
|
|---|
| 777 | * LPDWORD lpFileSizeHigh // pointer to DWORD to receive
|
|---|
| 778 | * high-order doubleword of file size
|
|---|
| 779 | * Variables :
|
|---|
| 780 | * Result : size of compressed file
|
|---|
| 781 | * Remark :
|
|---|
| 782 | * Status : UNTESTED
|
|---|
| 783 | *
|
|---|
| 784 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
|---|
| 785 | *****************************************************************************/
|
|---|
| 786 |
|
|---|
| 787 | DWORD WIN32API GetCompressedFileSizeW(LPCWSTR lpFileName,
|
|---|
| 788 | LPDWORD lpFileSizeHigh)
|
|---|
| 789 | {
|
|---|
| 790 | LPCTSTR lpAsciiFileName; /* converted filename */
|
|---|
| 791 | DWORD rc; /* function result */
|
|---|
| 792 |
|
|---|
| 793 | dprintf(("KERNEL32: GetCompressedFileSizeW (%s, %08xh)\n",
|
|---|
| 794 | lpFileName,
|
|---|
| 795 | lpFileSizeHigh));
|
|---|
| 796 |
|
|---|
| 797 | lpAsciiFileName = UnicodeToAsciiString( (LPWSTR) lpFileName);
|
|---|
| 798 |
|
|---|
| 799 | rc = GetCompressedFileSizeA(lpAsciiFileName,
|
|---|
| 800 | lpFileSizeHigh);
|
|---|
| 801 |
|
|---|
| 802 | FreeAsciiString( (char *) lpAsciiFileName);
|
|---|
| 803 |
|
|---|
| 804 | return (rc); /* return result */
|
|---|
| 805 | }
|
|---|