Skip to content

Commit

Permalink
Using centralized ResolveAppRelativePathToFileSystem method (attempts…
Browse files Browse the repository at this point in the history
… to handle platform specifics)
  • Loading branch information
AlexCuse committed May 23, 2011
1 parent 6c9c4f5 commit d1a2d91
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
20 changes: 2 additions & 18 deletions SquishIt.Framework/Base/BundleBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private List<InputFile> GetInputFiles(List<Asset> assets)

private InputFile GetFileSystemPath(string localPath)
{
string mappedPath = ResolveAppRelativePathToFileSystem(localPath);
string mappedPath = FileSystem.ResolveAppRelativePathToFileSystem(localPath);
return new InputFile(mappedPath, ResolverFactory.Get<FileResolver>());
}

Expand All @@ -96,22 +96,6 @@ private InputFile GetEmbeddedResourcePath(string resourcePath)
return new InputFile(resourcePath, ResolverFactory.Get<EmbeddedResourceResolver>());
}

protected string ResolveAppRelativePathToFileSystem(string file)
{
// Remove query string
if (file.IndexOf('?') != -1)
{
file = file.Substring(0, file.IndexOf('?'));
}

if (HttpContext.Current == null)
{
file = file.Replace("/", "\\").TrimStart('~').TrimStart('\\');
return @"C:\" + file.Replace("/", "\\");
}
return HttpContext.Current.Server.MapPath(file);
}

private string ExpandAppRelativePath(string file)
{
if (file.StartsWith("~/"))
Expand Down Expand Up @@ -322,7 +306,7 @@ private string RenderRelease(string key, string renderTo, IRenderer renderer)
renderPathCache[CachePrefix + "." + group + "." + key] = renderTo;
}

string outputFile = ResolveAppRelativePathToFileSystem(renderTo);
string outputFile = FileSystem.ResolveAppRelativePathToFileSystem(renderTo);
var renderToPath = ExpandAppRelativePath(renderTo);

var localAssetPaths = new List<string>();
Expand Down
4 changes: 2 additions & 2 deletions SquishIt.Framework/Css/CssBundle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private string ProcessImport(string css)

private string ApplyFileContentsToMatchedImport(Match match)
{
var file = ResolveAppRelativePathToFileSystem(match.Groups[2].Value);
var file = FileSystem.ResolveAppRelativePathToFileSystem(match.Groups[2].Value);
DependentFiles.Add(file);
return ReadFile(file);
}
Expand Down Expand Up @@ -145,7 +145,7 @@ internal override Dictionary<string, GroupBundle> BeforeRenderDebug()
var localPath = asset.LocalPath;
if (localPath.ToLower().EndsWith(".less") || localPath.ToLower().EndsWith(".less.css"))
{
string outputFile = ResolveAppRelativePathToFileSystem(localPath);
string outputFile = FileSystem.ResolveAppRelativePathToFileSystem(localPath);
string css = ProcessLess(outputFile);
outputFile += ".debug.css";
using (var fileWriter = fileWriterFactory.GetFileWriter(outputFile))
Expand Down

0 comments on commit d1a2d91

Please sign in to comment.