jgauffin / Griffin.WebServer

A web server built on top of Griffin.Framework
107 stars 42 forks source link

IFileService should provide a method to see if a file exists #24

Open wo80 opened 8 years ago

wo80 commented 8 years ago

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.

jgauffin commented 9 months ago

@wo80 Want to contribute to the project?

wo80 commented 9 months ago

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?

jgauffin commented 9 months ago

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.

wo80 commented 9 months ago

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.