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