Skip to content

Commit

Permalink
Make FileCache work on non-Windows platforms (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
cbiesinger authored and sanketj committed May 2, 2019
1 parent 4093b9a commit f1773d5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
19 changes: 19 additions & 0 deletions server/JsDbg.Core/DllImports.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//--------------------------------------------------------------
//
// MIT License
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//--------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;

namespace JsDbg.Core {
internal class DllImports {
[DllImport("shlwapi.dll")]
internal static extern bool PathIsNetworkPath(string path);
}
}
9 changes: 7 additions & 2 deletions server/JsDbg.Core/FileCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@ internal FileCache() {
this.lastFlushDate = DateTime.Now;
}

[DllImport("shlwapi.dll")]
internal static extern bool PathIsNetworkPath(string path);
internal static bool PathIsNetworkPath(string path) {
try {
return DllImports.PathIsNetworkPath(path);
} catch (DllNotFoundException) {
return false;
}
}

internal Stream ReadFile(string path) {
// Flush the cache every hour for the scenario where JsDbg is left open overnight etc.
Expand Down
1 change: 1 addition & 0 deletions server/JsDbg.Core/JsDbg.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
<Compile Include="PersistentStore.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="WebServer.cs" />
<Compile Include="DllImports.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
Expand Down

0 comments on commit f1773d5

Please sign in to comment.