comparison src/nt.c @ 359:8e84bee8ddd0 r21-1-9

Import from CVS: tag r21-1-9
author cvs
date Mon, 13 Aug 2007 10:57:55 +0200
parents c6de09ad3017
children a4f53d9b3154
comparison
equal deleted inserted replaced
358:fed6e0f6a03a 359:8e84bee8ddd0
1286 char fullname[ MAX_PATH ]; 1286 char fullname[ MAX_PATH ];
1287 char * p; 1287 char * p;
1288 unsigned hash; 1288 unsigned hash;
1289 1289
1290 /* Get the truly canonical filename, if it exists. (Note: this 1290 /* Get the truly canonical filename, if it exists. (Note: this
1291 doesn't resolve aliasing due to subst commands, or recognise hard 1291 doesn't resolve aliasing due to subst commands, or recognize hard
1292 links. */ 1292 links. */
1293 if (!win32_get_long_filename ((char *)name, fullname, MAX_PATH)) 1293 if (!win32_get_long_filename ((char *)name, fullname, MAX_PATH))
1294 abort (); 1294 abort ();
1295 1295
1296 parse_root (fullname, &p); 1296 parse_root (fullname, &p);
1298 _strlwr (p); 1298 _strlwr (p);
1299 return hashval (p); 1299 return hashval (p);
1300 } 1300 }
1301 1301
1302 #endif 1302 #endif
1303
1304 /* Since stat is encapsulated on Windows NT, we need to encapsulate
1305 the equally broken fstat as well. */
1306 int
1307 fstat (int handle, struct stat *buffer)
1308 {
1309 int ret;
1310 BY_HANDLE_FILE_INFORMATION lpFileInfo;
1311 /* Initialize values */
1312 buffer->st_mode = 0;
1313 buffer->st_size = 0;
1314 buffer->st_dev = 0;
1315 buffer->st_rdev = 0;
1316 buffer->st_atime = 0;
1317 buffer->st_ctime = 0;
1318 buffer->st_mtime = 0;
1319 buffer->st_nlink = 0;
1320 ret = GetFileInformationByHandle((HANDLE) handle, &lpFileInfo);
1321 if (!ret)
1322 {
1323 return -1;
1324 }
1325 else
1326 {
1327 buffer->st_mtime = convert_time (lpFileInfo.ftLastWriteTime);
1328 buffer->st_atime = convert_time (lpFileInfo.ftLastAccessTime);
1329 if (buffer->st_atime == 0) buffer->st_atime = buffer->st_mtime;
1330 buffer->st_ctime = convert_time (lpFileInfo.ftCreationTime);
1331 if (buffer->st_ctime == 0) buffer->st_ctime = buffer->st_mtime;
1332 buffer->st_size = lpFileInfo.nFileSizeLow;
1333 buffer->st_nlink = (short) lpFileInfo.nNumberOfLinks;
1334 return 0;
1335 }
1336 }
1303 1337
1304 /* MSVC stat function can't cope with UNC names and has other bugs, so 1338 /* MSVC stat function can't cope with UNC names and has other bugs, so
1305 replace it with our own. This also allows us to calculate consistent 1339 replace it with our own. This also allows us to calculate consistent
1306 inode values without hacks in the main Emacs code. */ 1340 inode values without hacks in the main Emacs code. */
1307 int 1341 int
1388 buf->st_nlink = 2; /* doesn't really matter */ 1422 buf->st_nlink = 2; /* doesn't really matter */
1389 fake_inode = 0; /* this doesn't either I think */ 1423 fake_inode = 0; /* this doesn't either I think */
1390 } 1424 }
1391 else if (!NILP (Vmswindows_get_true_file_attributes)) 1425 else if (!NILP (Vmswindows_get_true_file_attributes))
1392 { 1426 {
1393 /* This is more accurate in terms of gettting the correct number 1427 /* This is more accurate in terms of getting the correct number
1394 of links, but is quite slow (it is noticable when Emacs is 1428 of links, but is quite slow (it is noticeable when Emacs is
1395 making a list of file name completions). */ 1429 making a list of file name completions). */
1396 BY_HANDLE_FILE_INFORMATION info; 1430 BY_HANDLE_FILE_INFORMATION info;
1397 1431
1398 /* No access rights required to get info. */ 1432 /* No access rights required to get info. */
1399 fh = CreateFile (name, 0, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, 1433 fh = CreateFile (name, 0, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
1861 1895
1862 /* Zero means stop timer */ 1896 /* Zero means stop timer */
1863 if (tv->tv_sec == 0 && tv->tv_usec == 0) 1897 if (tv->tv_sec == 0 && tv->tv_usec == 0)
1864 return 0; 1898 return 0;
1865 1899
1866 /* Conver to ms and divide by denom */ 1900 /* Convert to ms and divide by denom */
1867 res = (tv->tv_sec * 1000 + (tv->tv_usec + 500) / 1000) / denom; 1901 res = (tv->tv_sec * 1000 + (tv->tv_usec + 500) / 1000) / denom;
1868 1902
1869 /* Converge to minimum timer resolution */ 1903 /* Converge to minimum timer resolution */
1870 if (time_caps.wPeriodMin == 0) 1904 if (time_caps.wPeriodMin == 0)
1871 timeGetDevCaps (&time_caps, sizeof(time_caps)); 1905 timeGetDevCaps (&time_caps, sizeof(time_caps));