Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

885 lines
19 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1996 - 1999
  6. //
  7. // File: file.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. #include "windows.h"
  11. #include <stdio.h>
  12. #include <string.h>
  13. #include <assert.h>
  14. #include "crtem.h"
  15. #include "unicode.h"
  16. #ifdef _M_IX86
  17. HANDLE WINAPI CreateFile9x (
  18. LPCWSTR lpFileName,
  19. DWORD dwDesiredAccess,
  20. DWORD dwShareMode,
  21. LPSECURITY_ATTRIBUTES lpSecurityAttributes,
  22. DWORD dwCreationDisposition,
  23. DWORD dwFlagsAndAttributes,
  24. HANDLE hTemplateFile
  25. ) {
  26. BYTE rgb[_MAX_PATH];
  27. char * szFileName;
  28. HANDLE hFile;
  29. hFile = INVALID_HANDLE_VALUE;
  30. if(MkMBStr(rgb, _MAX_PATH, lpFileName, &szFileName))
  31. hFile = CreateFileA (
  32. szFileName,
  33. dwDesiredAccess,
  34. dwShareMode,
  35. lpSecurityAttributes,
  36. dwCreationDisposition,
  37. dwFlagsAndAttributes,
  38. hTemplateFile
  39. );
  40. FreeMBStr(rgb, szFileName);
  41. return(hFile);
  42. }
  43. HANDLE WINAPI CreateFileU (
  44. LPCWSTR lpFileName,
  45. DWORD dwDesiredAccess,
  46. DWORD dwShareMode,
  47. LPSECURITY_ATTRIBUTES lpSecurityAttributes,
  48. DWORD dwCreationDisposition,
  49. DWORD dwFlagsAndAttributes,
  50. HANDLE hTemplateFile
  51. ) {
  52. if(FIsWinNT())
  53. return( CreateFileW (
  54. lpFileName,
  55. dwDesiredAccess,
  56. dwShareMode,
  57. lpSecurityAttributes,
  58. dwCreationDisposition,
  59. dwFlagsAndAttributes,
  60. hTemplateFile
  61. ));
  62. else
  63. return( CreateFile9x (
  64. lpFileName,
  65. dwDesiredAccess,
  66. dwShareMode,
  67. lpSecurityAttributes,
  68. dwCreationDisposition,
  69. dwFlagsAndAttributes,
  70. hTemplateFile
  71. ));
  72. }
  73. BOOL
  74. WINAPI
  75. DeleteFile9x(
  76. LPCWSTR lpFileName
  77. )
  78. {
  79. BYTE rgb[_MAX_PATH];
  80. char * szFileName;
  81. BOOL fResult;
  82. fResult = FALSE;
  83. if(MkMBStr(rgb, _MAX_PATH, lpFileName, &szFileName))
  84. fResult = DeleteFileA (
  85. szFileName
  86. );
  87. FreeMBStr(rgb, szFileName);
  88. return(fResult);
  89. }
  90. BOOL
  91. WINAPI
  92. DeleteFileU(
  93. LPCWSTR lpFileName
  94. )
  95. {
  96. if(FIsWinNT())
  97. return( DeleteFileW (lpFileName) );
  98. else
  99. return( DeleteFile9x (lpFileName) );
  100. }
  101. BOOL
  102. WINAPI
  103. CopyFile9x(LPCWSTR lpwExistingFileName, LPCWSTR lpwNewFileName, BOOL bFailIfExists)
  104. {
  105. BYTE rgbexist[_MAX_PATH];
  106. BYTE rgbnew[_MAX_PATH];
  107. char * szFileNameExist;
  108. char * szFileNameNew;
  109. BOOL fResult;
  110. fResult = FALSE;
  111. if (!(MkMBStr(rgbexist, _MAX_PATH, lpwExistingFileName, &szFileNameExist)))
  112. {
  113. return(FALSE);
  114. }
  115. if (!(MkMBStr(rgbnew, _MAX_PATH, lpwNewFileName, &szFileNameNew)))
  116. {
  117. FreeMBStr(rgbexist, szFileNameExist);
  118. return(FALSE);
  119. }
  120. fResult = CopyFileA(szFileNameExist, szFileNameNew, bFailIfExists);
  121. FreeMBStr(rgbexist, szFileNameExist);
  122. FreeMBStr(rgbnew, szFileNameNew);
  123. return(fResult);
  124. }
  125. BOOL
  126. WINAPI
  127. CopyFileU(LPCWSTR lpwExistingFileName, LPCWSTR lpwNewFileName, BOOL bFailIfExists)
  128. {
  129. if (FIsWinNT())
  130. return( CopyFileW(lpwExistingFileName, lpwNewFileName, bFailIfExists) );
  131. else
  132. return( CopyFile9x(lpwExistingFileName, lpwNewFileName, bFailIfExists) );
  133. }
  134. BOOL
  135. WINAPI
  136. MoveFileEx9x(
  137. LPCWSTR lpExistingFileName, // address of name of the existing file
  138. LPCWSTR lpNewFileName, // address of new name for the file
  139. DWORD dwFlags) // flag to determine how to move file
  140. {
  141. BYTE rgbExisting[_MAX_PATH];
  142. BYTE rgbNew[_MAX_PATH];
  143. char * szExisting = NULL;
  144. char * szNew = NULL;
  145. BOOL bResult = FALSE;
  146. if ((MkMBStr(rgbExisting, _MAX_PATH, lpExistingFileName, &szExisting)) &&
  147. (MkMBStr(rgbNew, _MAX_PATH, lpNewFileName, &szNew)))
  148. {
  149. bResult = MoveFileExA(szExisting, szNew, dwFlags);
  150. }
  151. FreeMBStr(rgbExisting, szExisting);
  152. FreeMBStr(rgbNew, szNew);
  153. return (bResult);
  154. }
  155. BOOL
  156. WINAPI
  157. MoveFileExU(
  158. LPCWSTR lpExistingFileName, // address of name of the existing file
  159. LPCWSTR lpNewFileName, // address of new name for the file
  160. DWORD dwFlags) // flag to determine how to move file
  161. {
  162. if (FIsWinNT())
  163. return(MoveFileExW(lpExistingFileName, lpNewFileName, dwFlags));
  164. else
  165. return(MoveFileEx9x(lpExistingFileName, lpNewFileName, dwFlags));
  166. }
  167. DWORD
  168. WINAPI
  169. GetFileAttributes9x(
  170. LPCWSTR lpFileName
  171. )
  172. {
  173. if (lpFileName == NULL) {
  174. SetLastError(ERROR_INVALID_PARAMETER);
  175. return(0xFFFFFFFF);
  176. }
  177. BYTE rgb[_MAX_PATH];
  178. char * szFileName;
  179. DWORD dwAttr;
  180. dwAttr = 0xFFFFFFFF;
  181. if(MkMBStr(rgb, _MAX_PATH, lpFileName, &szFileName))
  182. dwAttr = GetFileAttributesA (
  183. szFileName
  184. );
  185. FreeMBStr(rgb, szFileName);
  186. return(dwAttr);
  187. }
  188. DWORD
  189. WINAPI
  190. GetFileAttributesU(
  191. LPCWSTR lpFileName
  192. )
  193. {
  194. if(FIsWinNT())
  195. return( GetFileAttributesW (lpFileName) );
  196. else
  197. return( GetFileAttributes9x (lpFileName) );
  198. }
  199. BOOL
  200. WINAPI
  201. SetFileAttributes9x(
  202. LPCWSTR lpFileName,
  203. DWORD dwFileAttributes
  204. )
  205. {
  206. if (lpFileName == NULL) {
  207. SetLastError(ERROR_INVALID_PARAMETER);
  208. return(0);
  209. }
  210. BYTE rgb[_MAX_PATH];
  211. char * szFileName;
  212. BOOL fResult;
  213. fResult = FALSE;
  214. if(MkMBStr(rgb, _MAX_PATH, lpFileName, &szFileName))
  215. fResult = SetFileAttributesA (
  216. szFileName,
  217. dwFileAttributes
  218. );
  219. FreeMBStr(rgb, szFileName);
  220. return(fResult);
  221. }
  222. BOOL
  223. WINAPI
  224. SetFileAttributesU(
  225. LPCWSTR lpFileName,
  226. DWORD dwFileAttributes
  227. )
  228. {
  229. if(FIsWinNT())
  230. return( SetFileAttributesW (lpFileName, dwFileAttributes) );
  231. else
  232. return( SetFileAttributes9x (lpFileName, dwFileAttributes) );
  233. }
  234. DWORD
  235. WINAPI
  236. GetCurrentDirectory9x(
  237. DWORD nBufferLength, // size, in characters, of directory buffer
  238. LPWSTR lpBuffer) // address of buffer for current directory
  239. {
  240. BYTE rgb[_MAX_PATH];
  241. char * szDir = NULL;
  242. DWORD dwResult = 0;
  243. if (nBufferLength == 0)
  244. {
  245. return(GetCurrentDirectoryA(0, NULL));
  246. }
  247. else
  248. {
  249. szDir = (char *) malloc(nBufferLength);
  250. if (szDir == NULL)
  251. {
  252. SetLastError(E_OUTOFMEMORY);
  253. return 0;
  254. }
  255. dwResult = GetCurrentDirectoryA(nBufferLength, szDir);
  256. if (dwResult == 0)
  257. {
  258. return 0;
  259. }
  260. MultiByteToWideChar(
  261. 0,
  262. 0,
  263. szDir,
  264. -1,
  265. lpBuffer,
  266. nBufferLength);
  267. }
  268. free(szDir);
  269. return (dwResult);
  270. }
  271. DWORD
  272. WINAPI
  273. GetCurrentDirectoryU(
  274. DWORD nBufferLength, // size, in characters, of directory buffer
  275. LPWSTR lpBuffer) // address of buffer for current directory
  276. {
  277. if (FIsWinNT())
  278. return(GetCurrentDirectoryW(nBufferLength, lpBuffer));
  279. else
  280. return(GetCurrentDirectory9x(nBufferLength, lpBuffer));
  281. }
  282. BOOL
  283. WINAPI
  284. CreateDirectory9x(
  285. LPCWSTR lpPathName,
  286. LPSECURITY_ATTRIBUTES lpSecurityAttributes
  287. )
  288. {
  289. if (lpPathName == NULL) {
  290. SetLastError(ERROR_INVALID_PARAMETER);
  291. return(0);
  292. }
  293. BYTE rgb[_MAX_PATH];
  294. char * szPathName;
  295. BOOL fResult;
  296. fResult = FALSE;
  297. if(MkMBStr(rgb, _MAX_PATH, lpPathName, &szPathName))
  298. fResult = CreateDirectoryA (
  299. szPathName,
  300. lpSecurityAttributes
  301. );
  302. FreeMBStr(rgb, szPathName);
  303. return(fResult);
  304. }
  305. BOOL
  306. WINAPI
  307. CreateDirectoryU(
  308. LPCWSTR lpPathName,
  309. LPSECURITY_ATTRIBUTES lpSecurityAttributes
  310. )
  311. {
  312. if(FIsWinNT())
  313. return( CreateDirectoryW (lpPathName, lpSecurityAttributes) );
  314. else
  315. return( CreateDirectory9x (lpPathName, lpSecurityAttributes) );
  316. }
  317. BOOL
  318. WINAPI
  319. RemoveDirectory9x(
  320. LPCWSTR lpPathName
  321. )
  322. {
  323. if (lpPathName == NULL) {
  324. SetLastError(ERROR_INVALID_PARAMETER);
  325. return(0);
  326. }
  327. BYTE rgb[_MAX_PATH];
  328. char * szPathName;
  329. BOOL fResult;
  330. fResult = FALSE;
  331. if(MkMBStr(rgb, _MAX_PATH, lpPathName, &szPathName))
  332. fResult = RemoveDirectoryA (
  333. szPathName
  334. );
  335. FreeMBStr(rgb, szPathName);
  336. return(fResult);
  337. }
  338. BOOL
  339. WINAPI
  340. RemoveDirectoryU(
  341. LPCWSTR lpPathName
  342. )
  343. {
  344. if(FIsWinNT())
  345. return( RemoveDirectoryW (lpPathName) );
  346. else
  347. return( RemoveDirectory9x (lpPathName) );
  348. }
  349. UINT
  350. WINAPI
  351. GetWindowsDirectory9x(
  352. LPWSTR lpBuffer,
  353. UINT uSize
  354. )
  355. {
  356. char rgch[_MAX_PATH];
  357. char * szDir = NULL;
  358. UINT cchDir;
  359. int cchConverted;
  360. UINT cch;
  361. szDir = rgch;
  362. cchDir = sizeof(rgch);
  363. if (0 == (cchDir = GetWindowsDirectoryA (
  364. szDir,
  365. cchDir))) goto ErrorReturn;
  366. // bump to include null terminator
  367. cchDir++;
  368. if (cchDir > sizeof(rgch)) {
  369. szDir = (char *) malloc(cchDir);
  370. if(!szDir) {
  371. SetLastError(ERROR_OUTOFMEMORY);
  372. goto ErrorReturn;
  373. }
  374. if (0 == (cchDir = GetWindowsDirectoryA (
  375. szDir,
  376. cchDir))) goto ErrorReturn;
  377. cchDir++;
  378. }
  379. // how long is the unicode string
  380. if (0 >= (cchConverted = MultiByteToWideChar(
  381. 0,
  382. 0,
  383. szDir,
  384. cchDir,
  385. NULL,
  386. 0)))
  387. goto ErrorReturn;
  388. if ((UINT) cchConverted <= uSize) {
  389. if (0 >= (cchConverted = MultiByteToWideChar(
  390. 0,
  391. 0,
  392. szDir,
  393. cchDir,
  394. lpBuffer,
  395. (int) uSize)))
  396. goto ErrorReturn;
  397. else
  398. // Don't include null terminating char if input buffer was large
  399. // enough
  400. cch = (UINT) cchConverted - 1;
  401. } else
  402. // Include null terminating if input buffer wasn't large enough
  403. cch = (UINT) cchConverted;
  404. CommonReturn:
  405. if (szDir != rgch && szDir)
  406. free(szDir);
  407. return cch;
  408. ErrorReturn:
  409. cch = 0;
  410. goto CommonReturn;
  411. }
  412. UINT
  413. WINAPI
  414. GetWindowsDirectoryU(
  415. LPWSTR lpBuffer,
  416. UINT uSize
  417. )
  418. {
  419. if(FIsWinNT())
  420. return( GetWindowsDirectoryW (lpBuffer, uSize));
  421. else
  422. return( GetWindowsDirectory9x (lpBuffer, uSize));
  423. }
  424. UINT WINAPI GetTempFileName9x(
  425. IN LPCWSTR lpPathName,
  426. IN LPCWSTR lpPrefixString,
  427. IN UINT uUnique,
  428. OUT LPWSTR lpTempFileName
  429. )
  430. {
  431. UINT uResult = 0;
  432. BYTE rgbPathName[_MAX_PATH];
  433. BYTE rgbPrefixString[_MAX_PATH];
  434. char* szPathName = NULL;
  435. char* szPrefixString = NULL;
  436. char szTempFileName[_MAX_PATH];
  437. if ((MkMBStr(rgbPathName, _MAX_PATH, lpPathName, &szPathName)) &&
  438. (MkMBStr(rgbPrefixString, _MAX_PATH, lpPrefixString, &szPrefixString)))
  439. {
  440. if ( ( uResult = GetTempFileNameA(
  441. szPathName,
  442. szPrefixString,
  443. uUnique,
  444. szTempFileName
  445. ) != 0 ) )
  446. {
  447. MultiByteToWideChar(
  448. CP_ACP,
  449. 0,
  450. szTempFileName,
  451. -1,
  452. lpTempFileName,
  453. MAX_PATH
  454. );
  455. }
  456. }
  457. FreeMBStr(rgbPathName, szPathName);
  458. FreeMBStr(rgbPrefixString, szPrefixString);
  459. return( uResult );
  460. }
  461. UINT WINAPI GetTempFileNameU(
  462. IN LPCWSTR lpPathName,
  463. IN LPCWSTR lpPrefixString,
  464. IN UINT uUnique,
  465. OUT LPWSTR lpTempFileName
  466. )
  467. {
  468. if(FIsWinNT())
  469. return( GetTempFileNameW(
  470. lpPathName,
  471. lpPrefixString,
  472. uUnique,
  473. lpTempFileName
  474. ) );
  475. else
  476. return( GetTempFileName9x(
  477. lpPathName,
  478. lpPrefixString,
  479. uUnique,
  480. lpTempFileName
  481. ) );
  482. }
  483. HINSTANCE WINAPI LoadLibrary9x(
  484. LPCWSTR lpLibFileName
  485. )
  486. {
  487. BYTE rgb[_MAX_PATH];
  488. char * szLibFileName;
  489. HINSTANCE hInst;
  490. hInst = NULL;
  491. if(MkMBStr(rgb, _MAX_PATH, lpLibFileName, &szLibFileName))
  492. hInst = LoadLibraryA (
  493. szLibFileName
  494. );
  495. FreeMBStr(rgb, szLibFileName);
  496. return(hInst);
  497. }
  498. HINSTANCE WINAPI LoadLibraryU(
  499. LPCWSTR lpLibFileName
  500. )
  501. {
  502. if(FIsWinNT())
  503. return( LoadLibraryW(lpLibFileName) );
  504. else
  505. return( LoadLibrary9x(lpLibFileName) );
  506. }
  507. HINSTANCE WINAPI LoadLibraryEx9x(
  508. LPCWSTR lpLibFileName,
  509. HANDLE hFile,
  510. DWORD dwFlags
  511. ){
  512. BYTE rgb[_MAX_PATH];
  513. char * szLibFileName;
  514. HINSTANCE hInst;
  515. hInst = NULL;
  516. if(MkMBStr(rgb, _MAX_PATH, lpLibFileName, &szLibFileName))
  517. hInst = LoadLibraryExA (
  518. szLibFileName,
  519. hFile,
  520. dwFlags
  521. );
  522. FreeMBStr(rgb, szLibFileName);
  523. return(hInst);
  524. }
  525. HINSTANCE WINAPI LoadLibraryExU(
  526. LPCWSTR lpLibFileName,
  527. HANDLE hFile,
  528. DWORD dwFlags
  529. ){
  530. if(FIsWinNT())
  531. return( LoadLibraryExW (
  532. lpLibFileName,
  533. hFile,
  534. dwFlags
  535. ));
  536. else
  537. return( LoadLibraryEx9x (
  538. lpLibFileName,
  539. hFile,
  540. dwFlags
  541. ));
  542. }
  543. DWORD
  544. WINAPI
  545. ExpandEnvironmentStrings9x(
  546. LPCWSTR lpSrc,
  547. LPWSTR lpDst,
  548. DWORD nSize
  549. )
  550. {
  551. BYTE rgb1[_MAX_PATH];
  552. char * szSrc = NULL;
  553. char rgch[_MAX_PATH];
  554. char * szDst = NULL;
  555. DWORD cchDst;
  556. int cbConverted;
  557. DWORD cch;
  558. if(!MkMBStr(rgb1, _MAX_PATH, lpSrc, &szSrc))
  559. goto ErrorReturn;
  560. szDst = rgch;
  561. cchDst = sizeof(rgch);
  562. if (0 == (cchDst = ExpandEnvironmentStringsA(
  563. szSrc,
  564. szDst,
  565. cchDst))) goto ErrorReturn;
  566. if (cchDst > sizeof(rgch)) {
  567. szDst = (char *) malloc(cchDst);
  568. if(!szDst) {
  569. SetLastError(ERROR_OUTOFMEMORY);
  570. goto ErrorReturn;
  571. }
  572. if (0 == (cchDst = ExpandEnvironmentStringsA(
  573. szSrc,
  574. szDst,
  575. cchDst))) goto ErrorReturn;
  576. }
  577. // how long is the unicode string
  578. if (0 >= (cbConverted = MultiByteToWideChar(
  579. 0,
  580. 0,
  581. szDst,
  582. cchDst,
  583. NULL,
  584. 0)))
  585. goto ErrorReturn;
  586. if ((DWORD) cbConverted <= nSize) {
  587. if (0 >= (cbConverted = MultiByteToWideChar(
  588. 0,
  589. 0,
  590. szDst,
  591. cchDst,
  592. lpDst,
  593. nSize)))
  594. goto ErrorReturn;
  595. }
  596. cch = (DWORD) cbConverted;
  597. CommonReturn:
  598. FreeMBStr(rgb1, szSrc);
  599. if (szDst != rgch && szDst)
  600. free(szDst);
  601. return cch;
  602. ErrorReturn:
  603. cch = 0;
  604. goto CommonReturn;
  605. }
  606. DWORD
  607. WINAPI
  608. ExpandEnvironmentStringsU(
  609. LPCWSTR lpSrc,
  610. LPWSTR lpDst,
  611. DWORD nSize
  612. )
  613. {
  614. if (lpSrc == NULL) {
  615. SetLastError(ERROR_INVALID_PARAMETER);
  616. return(0);
  617. }
  618. if(FIsWinNT())
  619. return( ExpandEnvironmentStringsW(
  620. lpSrc,
  621. lpDst,
  622. nSize
  623. ));
  624. else
  625. return( ExpandEnvironmentStrings9x(
  626. lpSrc,
  627. lpDst,
  628. nSize
  629. ));
  630. }
  631. void
  632. ConvertFindDataAToFindDataW(
  633. IN LPWIN32_FIND_DATAA pFindFileDataA,
  634. OUT LPWIN32_FIND_DATAW pFindFileDataW
  635. )
  636. {
  637. DWORD cchFilename;
  638. memset(pFindFileDataW, 0, sizeof(*pFindFileDataW));
  639. pFindFileDataW->dwFileAttributes = pFindFileDataA->dwFileAttributes;
  640. pFindFileDataW->ftCreationTime = pFindFileDataA->ftCreationTime;
  641. pFindFileDataW->ftLastAccessTime = pFindFileDataA->ftLastAccessTime;
  642. pFindFileDataW->ftLastWriteTime = pFindFileDataA->ftLastWriteTime;
  643. pFindFileDataW->nFileSizeHigh = pFindFileDataA->nFileSizeHigh;
  644. pFindFileDataW->nFileSizeLow = pFindFileDataA->nFileSizeLow;
  645. // pFindFileDataW->dwReserved0 = pFindFileDataA->dwReserved0;
  646. // pFindFileDataW->dwReserved1 = pFindFileDataA->dwReserved1;
  647. // CHAR cFileName[ MAX_PATH ];
  648. // pFindFileDataW->cAlternateFileName = pFindFileDataA->cAlternateFileName;
  649. cchFilename = strlen(pFindFileDataA->cFileName);
  650. if (0 != cchFilename && MAX_PATH > cchFilename)
  651. MultiByteToWideChar(
  652. CP_ACP,
  653. 0, // dwFlags
  654. pFindFileDataA->cFileName,
  655. cchFilename + 1,
  656. pFindFileDataW->cFileName,
  657. MAX_PATH
  658. );
  659. }
  660. HANDLE
  661. WINAPI
  662. FindFirstFile9x(
  663. IN LPCWSTR pwszDir,
  664. OUT LPWIN32_FIND_DATAW lpFindFileData
  665. )
  666. {
  667. HANDLE hFindFile;
  668. BYTE rgb[_MAX_PATH];
  669. WIN32_FIND_DATAA FindFileDataA;
  670. LPSTR pszDir;
  671. if (pwszDir == NULL) {
  672. SetLastError(ERROR_INVALID_PARAMETER);
  673. return(INVALID_HANDLE_VALUE);
  674. }
  675. if (!MkMBStr(rgb, _MAX_PATH, pwszDir, &pszDir))
  676. return INVALID_HANDLE_VALUE;
  677. hFindFile = FindFirstFileA(pszDir, &FindFileDataA);
  678. if (INVALID_HANDLE_VALUE != hFindFile)
  679. ConvertFindDataAToFindDataW(&FindFileDataA, lpFindFileData);
  680. FreeMBStr(rgb, pszDir);
  681. return hFindFile;
  682. }
  683. HANDLE
  684. WINAPI
  685. FindFirstFileU(
  686. IN LPCWSTR pwszDir,
  687. OUT LPWIN32_FIND_DATAW lpFindFileData
  688. )
  689. {
  690. if (FIsWinNT())
  691. return FindFirstFileW(pwszDir, lpFindFileData);
  692. else
  693. return FindFirstFile9x(pwszDir, lpFindFileData);
  694. }
  695. BOOL
  696. WINAPI
  697. FindNextFile9x(
  698. IN HANDLE hFindFile,
  699. OUT LPWIN32_FIND_DATAW lpFindFileData
  700. )
  701. {
  702. BOOL fResult;
  703. WIN32_FIND_DATAA FindFileDataA;
  704. fResult = FindNextFileA(hFindFile, &FindFileDataA);
  705. if (fResult)
  706. ConvertFindDataAToFindDataW(&FindFileDataA, lpFindFileData);
  707. return fResult;
  708. }
  709. BOOL
  710. WINAPI
  711. FindNextFileU(
  712. IN HANDLE hFindFile,
  713. OUT LPWIN32_FIND_DATAW lpFindFileData
  714. )
  715. {
  716. if (FIsWinNT())
  717. return FindNextFileW(hFindFile, lpFindFileData);
  718. else
  719. return FindNextFile9x(hFindFile, lpFindFileData);
  720. }
  721. HANDLE
  722. WINAPI
  723. FindFirstChangeNotification9x(
  724. LPCWSTR pwszPath,
  725. BOOL bWatchSubtree,
  726. DWORD dwNotifyFilter
  727. )
  728. {
  729. HANDLE hChange;
  730. BYTE rgb[_MAX_PATH];
  731. LPSTR pszPath;
  732. if (pwszPath == NULL) {
  733. SetLastError(ERROR_INVALID_PARAMETER);
  734. return INVALID_HANDLE_VALUE;
  735. }
  736. if (!MkMBStr(rgb, _MAX_PATH, pwszPath, &pszPath))
  737. return INVALID_HANDLE_VALUE;
  738. hChange = FindFirstChangeNotificationA(pszPath, bWatchSubtree,
  739. dwNotifyFilter);
  740. FreeMBStr(rgb, pszPath);
  741. return hChange;
  742. }
  743. HANDLE
  744. WINAPI
  745. FindFirstChangeNotificationU(
  746. LPCWSTR pwszPath,
  747. BOOL bWatchSubtree,
  748. DWORD dwNotifyFilter
  749. )
  750. {
  751. if (FIsWinNT())
  752. return FindFirstChangeNotificationW(
  753. pwszPath,
  754. bWatchSubtree,
  755. dwNotifyFilter);
  756. else
  757. return FindFirstChangeNotification9x(
  758. pwszPath,
  759. bWatchSubtree,
  760. dwNotifyFilter);
  761. }
  762. #endif // _M_IX86