Griffin.WebServer icon indicating copy to clipboard operation
Griffin.WebServer copied to clipboard

IFileService should provide a method to see if a file exists

Open wo80 opened this issue 9 years ago • 4 comments

Having a IFileService.FileExists(Uri uri, string fileName) method would allow re-using the IFileService in the DefaultDocumentRouter (instead of passing a root dir and duplicating the path calculation).

EDIT: The DiskFileService implementation could look something like

/// <summary>
/// Check if the specified url is a directory and if it contains the specified file.
/// </summary>
/// <param name="uri">Uri</param>
/// <param name="fileName">File name</param>
/// <returns></returns>
public bool FileExists(Uri uri, string fileName)
{
    if (fileName == null) return false;

    var path = GetFullPath(uri);

    if (!Directory.Exists(path)) return false;

    return File.Exists(Path.Combine(path, fileName));
}

EDIT 2: Or have two methods

// Check if file or directory exists.
bool Exists(Uri uri);

// Check if uri is directory and contains given file.
bool Exists(Uri uri, string file);

Alternatively, adding GetFullPath to the interface would solve the problem.

wo80 avatar Oct 24 '15 22:10 wo80

@wo80 Want to contribute to the project?

jgauffin avatar Sep 15 '23 05:09 jgauffin

Haven't used this in a while. I was just cleaning up Github issues that seemed stale / not relevant anymore.

Sure I could do a pull request. But both this project and Griffin.Framework look abandoned. Do you have any plans to revive them?

wo80 avatar Sep 15 '23 06:09 wo80

I still use Griffin.Framework. working on a new and more modern networking layer in it (although slowly). also moving the data mapper to a separate repository.

jgauffin avatar Sep 15 '23 12:09 jgauffin

Yeah, I saw the new_networking_code branch. Hope you find some time to finish this, looks promising!

I'll do the pull request, but since I don't have the framework targets for legacy net4 versions installed, I'd have to remove those from the project file.

wo80 avatar Sep 15 '23 14:09 wo80