Changeset 13967


Ignore:
Timestamp:
Feb 4, 2013, 8:57:20 PM (8 years ago)
Author:
jordan
Message:

(libT) add rb07's win32 implementation of tr_is_same_file().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/utils.c

    r13895 r13967  
    14761476tr_is_same_file (const char * filename1, const char * filename2)
    14771477{
     1478#ifdef WIN32
     1479
     1480  bool res;
     1481  HANDLE fh1, fh2;
     1482  BY_HANDLE_FILE_INFORMATION fi1, fi2;
     1483  int n = strlen (filename1) + 1;
     1484  int m = strlen (filename2) + 1;
     1485  wchar_t f1nameUTF16[n];
     1486  wchar_t f2nameUTF16[m];
     1487 
     1488  MultiByteToWideChar (CP_UTF8, 0, filename1, -1, f1nameUTF16, n);
     1489  MultiByteToWideChar (CP_UTF8, 0, filename2, -1, f2nameUTF16, m);
     1490  fh1 = CreateFileW (chkFilename (f1nameUTF16), 0, 0, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
     1491  fh2 = CreateFileW (chkFilename (f2nameUTF16), 0, 0, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
     1492  res = GetFileInformationByHandle (fh1, &fi1)
     1493          && GetFileInformationByHandle (fh2, &fi2)
     1494          && (fi1.dwVolumeSerialNumber == fi2.dwVolumeSerialNumber)
     1495          && (fi1.nFileIndexHigh == fi2.nFileIndexHigh)
     1496          && (fi1.nFileIndexLow  == fi2.nFileIndexLow);
     1497  CloseHandle (fh1);
     1498  CloseHandle (fh2);
     1499  return res;
     1500
     1501#else
     1502
    14781503  struct stat sb1, sb2;
    14791504
     
    14821507      && (sb1.st_dev == sb2.st_dev)
    14831508      && (sb1.st_ino == sb2.st_ino);
     1509
     1510#endif
    14841511}
    14851512
Note: See TracChangeset for help on using the changeset viewer.