Changeset 1222


Ignore:
Timestamp:
09/29/09 14:47:29 (5 years ago)
Author:
lowjoel
Message:

Standardise the file naming. The \ is a path separator so to refer to the root it is actually a blank string.

Location:
trunk/eraser6
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/eraser6/Eraser.Util.FileSystem/Fat32Api.cpp

    r1220 r1222  
    116116    { 
    117117        //The path must start with a backslash as it must be volume-relative. 
    118         if (path[0] != L'\\') 
     118        if (path->Length != 0 && path[0] != L'\\') 
    119119            throw gcnew ArgumentException(L"The path provided is not volume relative. " + 
    120120                gcnew String(L"Volume relative paths must begin with a backslash.")); 
    121121 
    122122        //Chop the path into it's constituent directory components 
    123         array<String^>^ components = path->Substring(1)->Split(Path::DirectorySeparatorChar, 
     123        array<String^>^ components = path->Split(Path::DirectorySeparatorChar, 
    124124            Path::AltDirectorySeparatorChar); 
    125125 
  • trunk/eraser6/Eraser.Util.FileSystem/FatApi.cpp

    r1220 r1222  
    8080    FatDirectory^ FatApi::LoadDirectory(String^ directory) 
    8181    { 
     82        //Return the root directory if nothing is specified 
     83        if (directory == String::Empty) 
     84            return LoadDirectory(DirectoryToCluster(directory), String::Empty, nullptr); 
     85 
    8286        array<wchar_t>^ pathSeparators = { Path::DirectorySeparatorChar, Path::AltDirectorySeparatorChar }; 
    83         DirectoryInfo^ info = gcnew DirectoryInfo(directory); 
    84         return LoadDirectory(DirectoryToCluster(directory), directory->Substring( 
    85                 directory->IndexOfAny(pathSeparators)), 
    86             info->Parent == nullptr ? nullptr : LoadDirectory(info->Parent->FullName)); 
     87        int lastIndex = directory->LastIndexOfAny(pathSeparators); 
     88        return LoadDirectory(DirectoryToCluster(directory), directory->Substring(lastIndex + 1), 
     89            LoadDirectory(directory->Substring(0, lastIndex == 0 ? 0 : lastIndex - 1))); 
    8790    } 
    8891 
  • trunk/eraser6/Eraser.Util/KernelApi.cs

    r1188 r1222  
    662662            public extern static bool DeviceIoControl(SafeFileHandle hDevice, 
    663663                uint dwIoControlCode, IntPtr lpInBuffer, uint nInBufferSize, 
     664                IntPtr lpOutBuffer, uint nOutBufferSize, out uint lpBytesReturned, 
     665                IntPtr lpOverlapped); 
     666            public const uint FSCTL_LOCK_VOLUME = 0x90018; 
     667            public const uint FSCTL_UNLOCK_VOLUME = 0x9001C; 
     668 
     669            [DllImport("Kernel32.dll", SetLastError = true)] 
     670            [return: MarshalAs(UnmanagedType.Bool)] 
     671            public extern static bool DeviceIoControl(SafeFileHandle hDevice, 
     672                uint dwIoControlCode, IntPtr lpInBuffer, uint nInBufferSize, 
    664673                out DiskPerformanceInfoInternal lpOutBuffer, uint nOutBufferSize, out uint lpBytesReturned, 
    665674                IntPtr lpOverlapped); 
Note: See TracChangeset for help on using the changeset viewer.