2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
11 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
18 #define WIN32_LEAN_AND_MEAN
23 // Global Variables ----------------------------------------------------------
25 static HANDLE _FindFileHandle = INVALID_HANDLE_VALUE;
28 static char *UnicodeToAsc(const wchar_t *w_str)
34 int len = wcslen(w_str) + 1;
35 str = (char *)malloc(len);
37 if (WideCharToMultiByte(CP_ACP, 0, w_str, -1, str, len, NULL, NULL) == 0)
43 { //Conversion successful
53 static wchar_t *AscToUnicode(const char *str)
55 wchar_t *w_str = NULL;
58 int len = strlen(str) + 1;
59 w_str = (wchar_t *)malloc(sizeof(wchar_t) * len);
60 if (MultiByteToWideChar(CP_ACP, 0, str, -1, w_str, len) == 0)
76 # define UnicodeToAsc(x) (x)
77 # define AscToUnicode(x) ((LPSTR)x)
82 int FileFindFirst(char *search_str, FILEFINDSTRUCT *ffstruct)
86 _FindFileHandle = FindFirstFile(AscToUnicode(search_str), &find);
87 if (_FindFileHandle == INVALID_HANDLE_VALUE) return 1;
89 ffstruct->size = find.nFileSizeLow;
90 strcpy(ffstruct->name, UnicodeToAsc(find.cFileName));
96 int FileFindNext(FILEFINDSTRUCT *ffstruct)
100 if (!FindNextFile(_FindFileHandle, &find)) return 1;
102 ffstruct->size = find.nFileSizeLow;
103 strcpy(ffstruct->name, UnicodeToAsc(find.cFileName));
109 int FileFindClose(void)
111 if (!FindClose(_FindFileHandle)) return 1;
117 int GetFileDateTime(int filehandle, FILETIMESTRUCT *ftstruct)
122 retval = GetFileTime((HANDLE)filehandle, NULL, NULL, &filetime);
124 FileTimeToDosDateTime(&filetime, &ftstruct->date, &ftstruct->time);
131 //returns 0 if no error
132 int SetFileDateTime(int filehandle, FILETIMESTRUCT *ftstruct)
137 DosDateTimeToFileTime(ftstruct->date, ftstruct->time, &ft);
138 retval = SetFileTime((HANDLE)filehandle, NULL, NULL, &ft);
139 if (retval) return 0;