Skip to content

Commit c02e180

Browse files
committed
minor changes to consisntely use Remove rather than delete
1 parent 5d2a888 commit c02e180

File tree

3 files changed

+26
-14
lines changed

3 files changed

+26
-14
lines changed

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ This is a library for dealing with File I/O on .NET that overcomes some limitati
44

55
It was created to factor out some of the file-system specific features that have built up in the [LessMSI project](https://github.com/activescott/lessmsi).
66

7+
78
Goals
89
========
910
* Support File I/O operations on Windows that .NET's System.IO libraries fail to support such as long paths (those longer than 260 characters).
1011
* Provide a basis for platform independent file system access across both Windows and Unix-like systems such as Linux and Mac OSX, and potentially others (cloud file storage?).
1112

13+
1214
Concepts & Usage
1315
========
1416
Two concepts are necessary to use the library `FileSystem` and `Path`. The static `FileSystem` class is a static class that contains all of the operations available on the `FileSystem`. Any operation that has a path argument, such as `FileSystem.CreateDirectory`, accepts paths as strongly typed `Path` objects rather than strings. For example,
@@ -20,10 +22,11 @@ Having paths strongly typed rather than strings forces the caller to be more exp
2022

2123
new Path(@"c:\src\\lessmsi") == new Path(@"c:\src\lessmsi") // true
2224

23-
`Path` has some handy shortcuts on it too such as Remove (delete) that calls back into the FileSystem to remove the file or directory at the current path:
25+
`Path` has some handy shortcuts on it too such as Exists that calls back into the FileSystem to determine if the file or directory at the current path already exists.
26+
These methods also provides some compatibility with existing code using System.IO.FileInfo or System.IO.DirectoryInfo so that in many cases you can replace usage of System.IO.FileInfo/DirectoryInfo with LessIO.Path.
2427

2528
Path destDir = new Path(@"c:\src\lessmsi");
26-
destDir.Remove();
29+
Console.WriteLine(destDir.Exists);
2730

2831
`Path` also offers some of the commonly used static methods on System.IO.Path to make the type relatively compatible with existing code using System.IO.Path. For example, `Combine` and `GetFileName` are available to make porting System.IO code easier:
2932

@@ -34,3 +37,10 @@ Having paths strongly typed rather than strings forces the caller to be more exp
3437
Platform Independence
3538
========
3639
The current implementation supports Win32 via the [Win32FileSystemStrategy.cs](https://github.com/activescott/LessIO/blob/master/src/LessIO/Strategies/Win32/Win32FileSystemStrategy.cs). However, adding support for another file system such as a Unixy file system could be done by implementing the ~10 methods on a class derived from [FileSystemStrategy](https://github.com/activescott/LessIO/blob/master/src/LessIO/Strategies/FileSystemStrategy.cs) and then updating the implementation of [FileSystem.LazyStrategy](https://github.com/activescott/LessIO/blob/master/src/LessIO/FileSystem.cs).
40+
41+
42+
Contributing
43+
========
44+
We accept pull requests! I think this is a sound basis, but obviously there are many improvements that could be made such as [improving platform independence by adding a new FileSystemStrategy](#platform-independence) or adding more static methods to [Path](https://github.com/activescott/LessIO/blob/master/src/LessIO/Path.cs) from System.IO.FileInfo/DirectoryInfo to make it easier to port System.IO code over to this library. There might also be some important methods missing on [FileSystem](https://github.com/activescott/LessIO/blob/master/src/LessIO/FileSystem.cs) as I just added the operations that [LessMSI](https://github.com/activescott/LessMSI) already uses which I imagine is fairly extensive but maybe not comprehensive.
45+
46+
Please do make sure that existing tests pass and please add new ones for the new features you write.

src/LessIO/FileSystem.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static void CreateDirectory(Path path)
6161
}
6262

6363
/// <summary>
64-
/// Deletes an existing empty directory.
64+
/// Removes/deletes an existing empty directory.
6565
/// See https://msdn.microsoft.com/en-us/library/windows/desktop/aa365488%28v=vs.85%29.aspx
6666
/// </summary>
6767
/// <param name="path"></param>
@@ -71,7 +71,7 @@ public static void RemoveDirectory(Path path)
7171
}
7272

7373
/// <summary>
74-
/// Deletes an existing empty directory.
74+
/// Removes/deletes an existing directory.
7575
/// See https://msdn.microsoft.com/en-us/library/windows/desktop/aa365488%28v=vs.85%29.aspx
7676
/// </summary>
7777
/// <param name="path">The path to the directory to remove.</param>
@@ -97,6 +97,17 @@ public static void RemoveFile(Path path, bool forcefully)
9797
Strategy.RemoveFile(path, forcefully);
9898
}
9999

100+
/// <summary>
101+
/// Removes/deletes an existing file.
102+
/// To remove a directory see <see cref="RemoveDirectory"/>.
103+
/// https://msdn.microsoft.com/en-us/library/windows/desktop/aa363915%28v=vs.85%29.aspx
104+
/// </summary>
105+
/// <param name="path">The file to remove.</param>
106+
public static void RemoveFile(Path path)
107+
{
108+
Strategy.RemoveFile(path, false);
109+
}
110+
100111
/// <summary>
101112
/// Copies the specified existing file to a new location.
102113
/// Will throw an exception if the destination file already exists.

src/LessIO/Path.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ public Path Parent
354354
}
355355

356356
/// <summary>
357+
/// Indicates if the file or directory at the specified path exists.
357358
/// For code compatibility with <see cref="System.IO.FileSystemInfo.Exists"/>.
358359
/// </summary>
359360
public bool Exists
@@ -381,16 +382,6 @@ public bool IsPathRooted
381382
}
382383
}
383384

384-
385-
386-
/// <summary>
387-
/// For code compatibility with <see cref="System.IO.FileSystemInfo.Delete()"/>
388-
/// </summary>
389-
public void Delete()
390-
{
391-
FileSystem.RemoveFile(this, false);
392-
}
393-
394385
/// <summary>
395386
/// For code compatibility with <see cref="System.IO.FileInfo.CreateText()"/>
396387
/// </summary>

0 commit comments

Comments
 (0)