Skip to content

Commit

Permalink
Add support for pathnames longer than 248 characters
Browse files Browse the repository at this point in the history
  • Loading branch information
Norbyte committed Jan 13, 2019
1 parent 73cb80f commit f835d0a
Show file tree
Hide file tree
Showing 19 changed files with 65 additions and 52 deletions.
8 changes: 4 additions & 4 deletions DebuggerFrontend/DebuggerFrontend.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="CommandLineArgumentsParser, Version=3.0.18.0, Culture=neutral, PublicKeyToken=16ad7bf6f4a1666c, processorArchitecture=MSIL">
<HintPath>..\packages\CommandLineArgumentsParser.3.0.18\lib\net45\CommandLineArgumentsParser.dll</HintPath>
<Reference Include="CommandLineArgumentsParser, Version=3.0.19.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CommandLineArgumentsParser.3.0.19\lib\net452\CommandLineArgumentsParser.dll</HintPath>
</Reference>
<Reference Include="Google.Protobuf, Version=3.6.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
<HintPath>..\packages\Google.Protobuf.3.6.1\lib\net45\Google.Protobuf.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="QUT.ShiftReduceParser">
<HintPath>..\External\gppg\binaries\QUT.ShiftReduceParser.dll</HintPath>
Expand Down
4 changes: 2 additions & 2 deletions DebuggerFrontend/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommandLineArgumentsParser" version="3.0.18" targetFramework="net461" />
<package id="CommandLineArgumentsParser" version="3.0.19" targetFramework="net462" />
<package id="Google.Protobuf" version="3.6.1" targetFramework="net461" />
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net462" />
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="net462" />
</packages>
9 changes: 1 addition & 8 deletions Divine/CLI/CommandLineActions.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using LSLib.LS.Enums;
using Alphaleonis.Win32.Filesystem;

namespace Divine.CLI
{
Expand Down Expand Up @@ -147,8 +147,6 @@ private static void Process(CommandLineArguments args)

public static string TryToValidatePath(string path)
{
const int maxPath = 248;

CommandLineLogger.LogDebug($"Using path: {path}");

if (string.IsNullOrWhiteSpace(path))
Expand All @@ -174,11 +172,6 @@ public static string TryToValidatePath(string path)
// ReSharper disable once AssignNullToNotNullAttribute
path = Path.GetFullPath(path);

if (path.Length > maxPath)
{
CommandLineLogger.LogFatal($"Cannot proceed with path exceeding {maxPath} characters: {path}", 1);
}

return path;
}
}
Expand Down
9 changes: 6 additions & 3 deletions Divine/Divine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,16 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="CommandLineArgumentsParser, Version=3.0.18.0, Culture=neutral, PublicKeyToken=16ad7bf6f4a1666c, processorArchitecture=MSIL">
<HintPath>..\packages\CommandLineArgumentsParser.3.0.18\lib\net45\CommandLineArgumentsParser.dll</HintPath>
<Private>True</Private>
<Reference Include="AlphaFS, Version=2.2.0.0, Culture=neutral, PublicKeyToken=4d31a58f7d7ad5c9, processorArchitecture=MSIL">
<HintPath>..\packages\AlphaFS.2.2.6\lib\net452\AlphaFS.dll</HintPath>
</Reference>
<Reference Include="CommandLineArgumentsParser, Version=3.0.19.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CommandLineArgumentsParser.3.0.19\lib\net452\CommandLineArgumentsParser.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Transactions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
Expand Down
4 changes: 2 additions & 2 deletions Divine/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>

<packages>
<package id="CommandLineArgumentsParser" version="3.0.18" targetFramework="net46" />
<package id="AlphaFS" version="2.2.6" targetFramework="net462" />
<package id="CommandLineArgumentsParser" version="3.0.19" targetFramework="net462" />
</packages>
6 changes: 5 additions & 1 deletion LSLib/Granny/GR2Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
using LSLib.Granny.GR2;
using LSLib.Granny.Model;
using LSLib.LS;
using Alphaleonis.Win32.Filesystem;
using Directory = Alphaleonis.Win32.Filesystem.Directory;
using Path = Alphaleonis.Win32.Filesystem.Path;
using File = Alphaleonis.Win32.Filesystem.File;

namespace LSLib.Granny
{
Expand Down Expand Up @@ -50,7 +54,7 @@ public static Root LoadModel(string inputPath, ExporterOptions options)
{
case ExportFormat.GR2:
{
using (var fs = new FileStream(inputPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var fs = File.Open(inputPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
var root = new Root();
var gr2 = new GR2Reader(fs);
Expand Down
6 changes: 4 additions & 2 deletions LSLib/Granny/Model/Exporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using System.Linq;
using LSLib.LS;
using OpenTK;
using Alphaleonis.Win32.Filesystem;
using File = Alphaleonis.Win32.Filesystem.File;

namespace LSLib.Granny.Model
{
Expand Down Expand Up @@ -108,7 +110,7 @@ public class Exporter
private Root LoadGR2(string inPath)
{
var root = new LSLib.Granny.Model.Root();
FileStream fs = new FileStream(inPath, FileMode.Open, System.IO.FileAccess.Read, FileShare.ReadWrite);
FileStream fs = File.Open(inPath, FileMode.Open, System.IO.FileAccess.Read, FileShare.ReadWrite);
var gr2 = new LSLib.Granny.GR2.GR2Reader(fs);
gr2.Read(root);
root.PostLoad(gr2.Tag);
Expand Down Expand Up @@ -158,7 +160,7 @@ private void SaveGR2(string outPath, Root root)
var body = writer.Write(root);
writer.Dispose();

FileStream f = new FileStream(outPath, FileMode.Create, System.IO.FileAccess.Write, FileShare.None);
FileStream f = File.Open(outPath, FileMode.Create, System.IO.FileAccess.Write, FileShare.None);
f.Write(body, 0, body.Length);
f.Close();
f.Dispose();
Expand Down
2 changes: 1 addition & 1 deletion LSLib/LS/Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public static class Common
{
public const int MajorVersion = 1;
public const int MinorVersion = 12;
public const int PatchVersion = 2;
public const int PatchVersion = 3;

/// <summary>
/// Returns the version number of the LSLib library
Expand Down
11 changes: 2 additions & 9 deletions LSLib/LS/FileManager.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using System;
using System.IO;
using Alphaleonis.Win32.Filesystem;

namespace LSLib.LS
{
internal class FileManager
{
private const int MaxPath = 248;

public static void TryToCreateDirectory(string path)
{
string outputPath = path;
Expand Down Expand Up @@ -41,12 +39,7 @@ public static void TryToCreateDirectory(string path)
{
throw new NullReferenceException("Cannot create directory without non-null output path");
}

if (outputPath.Length > MaxPath)
{
throw new PathTooLongException($"Cannot create directory in path exceeding {MaxPath} characters");
}


// if the directory does not exist, create the directory
if (!Directory.Exists(outputPath))
{
Expand Down
9 changes: 7 additions & 2 deletions LSLib/LS/PackageCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
using System.Text;
using LSLib.LS.Enums;
using LSLib.Native;
using Alphaleonis.Win32.Filesystem;
using Path = Alphaleonis.Win32.Filesystem.Path;
using FileInfo = Alphaleonis.Win32.Filesystem.FileInfo;
using Directory = Alphaleonis.Win32.Filesystem.Directory;
using File = Alphaleonis.Win32.Filesystem.File;

namespace LSLib.LS
{
Expand Down Expand Up @@ -247,7 +252,7 @@ public void Dispose()

public override UInt32 CRC() => throw new NotImplementedException("!");

public override Stream MakeStream() => _stream ?? (_stream = new FileStream(FilesystemPath, FileMode.Open, FileAccess.Read));
public override Stream MakeStream() => _stream ?? (_stream = File.Open(FilesystemPath, FileMode.Open, FileAccess.Read));

public override void ReleaseStream()
{
Expand Down Expand Up @@ -362,7 +367,7 @@ public void UncompressPackage(string packagePath, string outputPath)
{
using (var inReader = new BinaryReader(inStream))
{
using (var outFile = new FileStream(outPath, FileMode.Create, FileAccess.Write))
using (var outFile = File.Open(outPath, FileMode.Create, FileAccess.Write))
{
int read;
while ((read = inReader.Read(buffer, 0, buffer.Length)) > 0)
Expand Down
6 changes: 4 additions & 2 deletions LSLib/LS/PackageReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using System.Runtime.InteropServices;
using System.Text;
using LZ4;
using Alphaleonis.Win32.Filesystem;
using File = Alphaleonis.Win32.Filesystem.File;

namespace LSLib.LS
{
Expand Down Expand Up @@ -46,7 +48,7 @@ private void OpenStreams(FileStream mainStream, int numParts)
for (var part = 1; part < numParts; part++)
{
string partPath = Package.MakePartFilename(_path, part);
_streams[part] = new FileStream(partPath, FileMode.Open, FileAccess.Read);
_streams[part] = File.Open(partPath, FileMode.Open, FileAccess.Read);
}
}

Expand Down Expand Up @@ -133,7 +135,7 @@ private Package ReadPackageV13(FileStream mainStream, BinaryReader reader)

public Package Read()
{
var mainStream = new FileStream(_path, FileMode.Open, FileAccess.Read);
var mainStream = File.Open(_path, FileMode.Open, FileAccess.Read);

using (var reader = new BinaryReader(mainStream, new UTF8Encoding(), true))
{
Expand Down
6 changes: 4 additions & 2 deletions LSLib/LS/PackageWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
using LSLib.LS.Enums;
using LSLib.Native;
using LZ4;
using Alphaleonis.Win32.Filesystem;
using File = Alphaleonis.Win32.Filesystem.File;

namespace LSLib.LS
{
Expand Down Expand Up @@ -49,7 +51,7 @@ public PackagedFileInfo WriteFile(AbstractFileInfo info)
{
// Start a new package file if the current one is full.
string partPath = Package.MakePartFilename(_path, _streams.Count);
var nextPart = new FileStream(partPath, FileMode.Create, FileAccess.Write);
var nextPart = File.Open(partPath, FileMode.Create, FileAccess.Write);
_streams.Add(nextPart);
}

Expand Down Expand Up @@ -297,7 +299,7 @@ public byte[] ComputeArchiveHash()

public void Write()
{
var mainStream = new FileStream(_path, FileMode.Create, FileAccess.Write);
var mainStream = File.Open(_path, FileMode.Create, FileAccess.Write);
_streams.Add(mainStream);

switch (Version)
Expand Down
8 changes: 6 additions & 2 deletions LSLib/LS/ResourceUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
using System.Collections.Generic;
using System.IO;
using LSLib.LS.Enums;
using Alphaleonis.Win32.Filesystem;
using Path = Alphaleonis.Win32.Filesystem.Path;
using Directory = Alphaleonis.Win32.Filesystem.Directory;
using File = Alphaleonis.Win32.Filesystem.File;

namespace LSLib.LS
{
Expand Down Expand Up @@ -40,7 +44,7 @@ public static Resource LoadResource(string inputPath)

public static Resource LoadResource(string inputPath, ResourceFormat format)
{
using (var stream = new FileStream(inputPath, FileMode.Open, FileAccess.Read))
using (var stream = File.Open(inputPath, FileMode.Open, FileAccess.Read))
{
return LoadResource(stream, format);
}
Expand Down Expand Up @@ -96,7 +100,7 @@ public static void SaveResource(Resource resource, string outputPath, ResourceFo
{
FileManager.TryToCreateDirectory(outputPath);

using (var file = new FileStream(outputPath, FileMode.Create, FileAccess.Write))
using (var file = File.Open(outputPath, FileMode.Create, FileAccess.Write))
{
switch (format)
{
Expand Down
8 changes: 6 additions & 2 deletions LSLib/LSLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,22 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="AlphaFS, Version=2.2.0.0, Culture=neutral, PublicKeyToken=4d31a58f7d7ad5c9, processorArchitecture=MSIL">
<HintPath>..\packages\AlphaFS.2.2.6\lib\net452\AlphaFS.dll</HintPath>
</Reference>
<Reference Include="LZ4, Version=1.0.15.93, Culture=neutral, PublicKeyToken=62e1b5ec1eec9bdd, processorArchitecture=MSIL">
<HintPath>..\packages\lz4net.1.0.15.93\lib\net4-client\LZ4.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="QUT.ShiftReduceParser">
<HintPath>..\external\gppg\binaries\QUT.ShiftReduceParser.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
<Reference Include="System.Transactions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
Expand Down
3 changes: 2 additions & 1 deletion LSLib/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AlphaFS" version="2.2.6" targetFramework="net462" />
<package id="lz4net" version="1.0.15.93" targetFramework="net462" />
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net462" />
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="net462" />
<package id="zlib.net" version="1.0.4.0" targetFramework="net45" />
</packages>
8 changes: 4 additions & 4 deletions StoryCompiler/StoryCompiler.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="CommandLineArgumentsParser, Version=3.0.18.0, Culture=neutral, PublicKeyToken=16ad7bf6f4a1666c, processorArchitecture=MSIL">
<HintPath>..\packages\CommandLineArgumentsParser.3.0.18\lib\net45\CommandLineArgumentsParser.dll</HintPath>
<Reference Include="CommandLineArgumentsParser, Version=3.0.19.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CommandLineArgumentsParser.3.0.19\lib\net452\CommandLineArgumentsParser.dll</HintPath>
</Reference>
<Reference Include="Google.Protobuf, Version=3.6.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
<HintPath>..\packages\Google.Protobuf.3.6.1\lib\net45\Google.Protobuf.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
4 changes: 2 additions & 2 deletions StoryCompiler/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommandLineArgumentsParser" version="3.0.18" targetFramework="net462" />
<package id="CommandLineArgumentsParser" version="3.0.19" targetFramework="net462" />
<package id="Google.Protobuf" version="3.6.1" targetFramework="net462" />
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net462" />
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="net462" />
</packages>
4 changes: 2 additions & 2 deletions StoryDecompiler/StoryDecompiler.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="CommandLineArgumentsParser, Version=3.0.18.0, Culture=neutral, PublicKeyToken=16ad7bf6f4a1666c, processorArchitecture=MSIL">
<HintPath>..\packages\CommandLineArgumentsParser.3.0.18\lib\net45\CommandLineArgumentsParser.dll</HintPath>
<Reference Include="CommandLineArgumentsParser, Version=3.0.19.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CommandLineArgumentsParser.3.0.19\lib\net452\CommandLineArgumentsParser.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
2 changes: 1 addition & 1 deletion StoryDecompiler/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommandLineArgumentsParser" version="3.0.18" targetFramework="net462" />
<package id="CommandLineArgumentsParser" version="3.0.19" targetFramework="net462" />
</packages>

0 comments on commit f835d0a

Please sign in to comment.