Newer
Older
BOOL WINAPI FileTimeToSystemTime( const FILETIME *ft, LPSYSTEMTIME syst )
DWORD remainder;
time_t xtime = DOSFS_FileTimeToUnixTime( ft, &remainder );
syst->wDayOfWeek = xtm->tm_wday;
syst->wDay = xtm->tm_mday;
syst->wHour = xtm->tm_hour;
syst->wMinute = xtm->tm_min;
syst->wSecond = xtm->tm_sec;
syst->wMilliseconds = remainder / 10000;
/***********************************************************************
* QueryDosDeviceA (KERNEL32.413)
*
* returns array of strings terminated by \0, terminated by \0
*/
DWORD WINAPI QueryDosDeviceA(LPCSTR devname,LPSTR target,DWORD bufsize)
TRACE("(%s,...)\n", devname ? devname : "<null>");
if (!devname) {
/* return known MSDOS devices */
strcpy(buffer,"CON COM1 COM2 LPT1 NUL ");
lstrcpynA(target,buffer,bufsize);
strcpy(buffer,"\\DEV\\");
strcat(buffer,devname);
lstrcpynA(target,buffer,bufsize);
return strlen(buffer);
}
/***********************************************************************
* QueryDosDeviceW (KERNEL32.414)
*
* returns array of strings terminated by \0, terminated by \0
*/
DWORD WINAPI QueryDosDeviceW(LPCWSTR devname,LPWSTR target,DWORD bufsize)
{
LPSTR devnameA = devname?HEAP_strdupWtoA(GetProcessHeap(),0,devname):NULL;
LPSTR targetA = (LPSTR)HeapAlloc(GetProcessHeap(),0,bufsize);
DWORD ret = QueryDosDeviceA(devnameA,targetA,bufsize);
lstrcpynAtoW(target,targetA,bufsize);
if (devnameA) HeapFree(GetProcessHeap(),0,devnameA);
if (targetA) HeapFree(GetProcessHeap(),0,targetA);
return ret;
}
/***********************************************************************
* SystemTimeToFileTime (KERNEL32.526)
*/
BOOL WINAPI SystemTimeToFileTime( const SYSTEMTIME *syst, LPFILETIME ft )
time_t utctime;
#else
struct tm xtm,*local_tm,*utc_tm;
time_t localtim,utctime;
#endif
xtm.tm_wday = syst->wDayOfWeek;
xtm.tm_mday = syst->wDay;
xtm.tm_hour = syst->wHour;
xtm.tm_min = syst->wMinute;
xtm.tm_sec = syst->wSecond; /* this is UTC */
xtm.tm_isdst = -1;
#ifdef HAVE_TIMEGM
utctime = timegm(&xtm);
DOSFS_UnixTimeToFileTime( utctime, ft,
syst->wMilliseconds * 10000 );
#else
localtim = mktime(&xtm); /* now we've got local time */
local_tm = localtime(&localtim);
utc_tm = gmtime(&localtim);
utctime = mktime(utc_tm);
DOSFS_UnixTimeToFileTime( 2*localtim -utctime, ft,
syst->wMilliseconds * 10000 );
#endif
/***********************************************************************
* DefineDosDeviceA (KERNEL32.182)
*/
BOOL WINAPI DefineDosDeviceA(DWORD flags,LPCSTR devname,LPCSTR targetpath) {
FIXME("(0x%08lx,%s,%s),stub!\n",flags,devname,targetpath);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
/*
--- 16 bit functions ---
*/
/*************************************************************************
* FindFirstFile16 (KERNEL.413)
*/
HANDLE16 WINAPI FindFirstFile16( LPCSTR path, WIN32_FIND_DATAA *data )
{
DOS_FULL_NAME full_name;
HGLOBAL16 handle;
FIND_FIRST_INFO *info;
data->dwReserved0 = data->dwReserved1 = 0x0;
if (!path) return 0;
if (!DOSFS_GetFullName( path, FALSE, &full_name ))
return INVALID_HANDLE_VALUE16;
if (!(handle = GlobalAlloc16( GMEM_MOVEABLE, sizeof(FIND_FIRST_INFO) )))
return INVALID_HANDLE_VALUE16;
info = (FIND_FIRST_INFO *)GlobalLock16( handle );
info->path = HEAP_strdupA( SystemHeap, 0, full_name.long_name );
info->long_mask = strrchr( info->path, '/' );
if (info->long_mask )
*(info->long_mask++) = '\0';
info->short_mask = NULL;
info->attr = 0xff;
if (path[0] && (path[1] == ':')) info->drive = toupper(*path) - 'A';
else info->drive = DRIVE_GetCurrentDrive();
info->cur_pos = 0;
info->dir = DOSFS_OpenDir( info->path );
GlobalUnlock16( handle );
if (!FindNextFile16( handle, data ))
{
FindClose16( handle );
SetLastError( ERROR_NO_MORE_FILES );
return INVALID_HANDLE_VALUE16;
}
return handle;
}
/*************************************************************************
* FindNextFile16 (KERNEL.414)
*/
BOOL16 WINAPI FindNextFile16( HANDLE16 handle, WIN32_FIND_DATAA *data )
{
FIND_FIRST_INFO *info;
if ((handle == INVALID_HANDLE_VALUE16) ||
!(info = (FIND_FIRST_INFO *)GlobalLock16( handle )))
{
SetLastError( ERROR_INVALID_HANDLE );
return FALSE;
}
GlobalUnlock16( handle );
if (!info->path || !info->dir)
{
SetLastError( ERROR_NO_MORE_FILES );
return FALSE;
}
if (!DOSFS_FindNextEx( info, data ))
{
DOSFS_CloseDir( info->dir ); info->dir = NULL;
HeapFree( SystemHeap, 0, info->path );
info->path = info->long_mask = NULL;
SetLastError( ERROR_NO_MORE_FILES );
return FALSE;
}
return TRUE;
}
/*************************************************************************
* FindClose16 (KERNEL.415)
*/
BOOL16 WINAPI FindClose16( HANDLE16 handle )
{
FIND_FIRST_INFO *info;
if ((handle == INVALID_HANDLE_VALUE16) ||
!(info = (FIND_FIRST_INFO *)GlobalLock16( handle )))
{
SetLastError( ERROR_INVALID_HANDLE );
return FALSE;
}
if (info->dir) DOSFS_CloseDir( info->dir );
if (info->path) HeapFree( SystemHeap, 0, info->path );
GlobalUnlock16( handle );
GlobalFree16( handle );
return TRUE;
}