RupertAvery / PSXPackager

A utility to convert Playstation disc images in various formats to PBP format and back
Other
230 stars 15 forks source link

[BUG] Duplicate App path when trying to access gameinfo.db #7

Closed bennydiamond closed 3 years ago

bennydiamond commented 3 years ago

Env: Ubuntu Server 18.04 x64, latest dotnet runtime framework installed. Using release package 1.4 from Github release page. Executable package uncompressed and executed directly in same folder the PSX isos are in.

Looking at stack trace, it looks like AppPath value is duplicated, leading to wrong absolute path.

$ mono PSXPackager.exe -l 9 -v 1 -g log.txt -i "*.cue" -o "converted/"
PSXPackager v1.4 by RupertAvery

Input : *.cue
Output: converted/
Compression Level: 9

Unhandled Exception:
System.IO.DirectoryNotFoundException: Could not find a part of the path "/media/4TB1/Torrents/complete/1G1R - Redump - Sony - PlayStation/toconvert/media/4TB1/Torrents/complete/1G1R - Redump - Sony - PlayStation/toconvert/Resources/gameinfo.db".
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x001cf] in <8f2c484307284b51944a1a13a14c0266>:0
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.IO.FileOptions options, System.String msgPath, System.Boolean bFromProxy, System.Boolean useLongPath, System.Boolean checkHost) [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0
  at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,int,System.IO.FileOptions,string,bool,bool,bool)
  at System.IO.StreamReader..ctor (System.String path, System.Text.Encoding encoding, System.Boolean detectEncodingFromByteOrderMarks, System.Int32 bufferSize, System.Boolean checkHost) [0x00079] in <8f2c484307284b51944a1a13a14c0266>:0
  at System.IO.StreamReader..ctor (System.String path, System.Text.Encoding encoding, System.Boolean detectEncodingFromByteOrderMarks, System.Int32 bufferSize) [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0
  at System.IO.StreamReader..ctor (System.String path, System.Boolean detectEncodingFromByteOrderMarks) [0x0000d] in <8f2c484307284b51944a1a13a14c0266>:0
  at System.IO.StreamReader..ctor (System.String path) [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0
  at (wrapper remoting-invoke-with-check) System.IO.StreamReader:.ctor (string)
  at System.IO.File.OpenText (System.String path) [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0
  at System.IO.File.ReadAllLines (System.String path) [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0
  at PSXPackager.GameDB..ctor (System.String path) [0x00011] in <aa583565f87241d38006e9f25226904a>:0
  at PSXPackager.Processing..ctor (PSXPackager.INotifier notifier, PSXPackager.IEventHandler eventHandler) [0x00015] in <aa583565f87241d38006e9f25226904a>:0
  at PSXPackager.Program.ProcessFiles (PSXPackager.ProcessOptions options) [0x00055] in <aa583565f87241d38006e9f25226904a>:0
  at PSXPackager.Program+<>c__DisplayClass2_0.<Main>b__0 (PSXPackager.Options o) [0x00305] in <aa583565f87241d38006e9f25226904a>:0
  at CommandLine.ParserResultExtensions.WithParsed[T] (CommandLine.ParserResult`1[T] result, System.Action`1[T] action) [0x00014] in <aa583565f87241d38006e9f25226904a>:0
  at PSXPackager.Program.Main (System.String[] args) [0x00067] in <aa583565f87241d38006e9f25226904a>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.DirectoryNotFoundException: Could not find a part of the path "/media/4TB1/Torrents/complete/1G1R - Redump - Sony - PlayStation/toconvert/media/4TB1/Torrents/complete/1G1R - Redump - Sony - PlayStation/toconvert/Resources/gameinfo.db".
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x001cf] in <8f2c484307284b51944a1a13a14c0266>:0
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.IO.FileOptions options, System.String msgPath, System.Boolean bFromProxy, System.Boolean useLongPath, System.Boolean checkHost) [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0
  at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,int,System.IO.FileOptions,string,bool,bool,bool)
  at System.IO.StreamReader..ctor (System.String path, System.Text.Encoding encoding, System.Boolean detectEncodingFromByteOrderMarks, System.Int32 bufferSize, System.Boolean checkHost) [0x00079] in <8f2c484307284b51944a1a13a14c0266>:0
  at System.IO.StreamReader..ctor (System.String path, System.Text.Encoding encoding, System.Boolean detectEncodingFromByteOrderMarks, System.Int32 bufferSize) [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0
  at System.IO.StreamReader..ctor (System.String path, System.Boolean detectEncodingFromByteOrderMarks) [0x0000d] in <8f2c484307284b51944a1a13a14c0266>:0
  at System.IO.StreamReader..ctor (System.String path) [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0
  at (wrapper remoting-invoke-with-check) System.IO.StreamReader:.ctor (string)
  at System.IO.File.OpenText (System.String path) [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0
  at System.IO.File.ReadAllLines (System.String path) [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0
  at PSXPackager.GameDB..ctor (System.String path) [0x00011] in <aa583565f87241d38006e9f25226904a>:0
  at PSXPackager.Processing..ctor (PSXPackager.INotifier notifier, PSXPackager.IEventHandler eventHandler) [0x00015] in <aa583565f87241d38006e9f25226904a>:0
  at PSXPackager.Program.ProcessFiles (PSXPackager.ProcessOptions options) [0x00055] in <aa583565f87241d38006e9f25226904a>:0
  at PSXPackager.Program+<>c__DisplayClass2_0.<Main>b__0 (PSXPackager.Options o) [0x00305] in <aa583565f87241d38006e9f25226904a>:0
  at CommandLine.ParserResultExtensions.WithParsed[T] (CommandLine.ParserResult`1[T] result, System.Action`1[T] action) [0x00014] in <aa583565f87241d38006e9f25226904a>:0
  at PSXPackager.Program.Main (System.String[] args) [0x00067] in <aa583565f87241d38006e9f25226904a>:0

/media/4TB1/Torrents/complete/1G1R - Redump - Sony - PlayStation/toconvert/media/4TB1/Torrents/complete/1G1R - Redump - Sony - PlayStation/toconvert/Resources/gameinfo.db

RupertAvery commented 3 years ago

That's weird. The code doesn't seem to be duplicating the path anywhere.

I was able to replicate it in WSL2, installed latest mono-devel.

If I run it with mono, the error above appears.

If I run it standalone, a different error appears:

Unhandled Exception: System.NotSupportedException: The given path's format is not supported.
   at System.Security.Permissions.FileIOPermission.EmulateFileIOPermissionChecks(String fullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShar
e share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolea
n useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileO
ptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 buffe
rSize, Boolean checkHost)
   at System.IO.StreamReader..ctor(String path, Encoding encoding)
   at System.IO.File.InternalReadAllLines(String path, Encoding encoding)
   at PSXPackager.GameDB..ctor(String path)
   at PSXPackager.Processing..ctor(INotifier notifier, IEventHandler eventHandler)
   at PSXPackager.Program.ProcessFiles(ProcessOptions options)
   at PSXPackager.Program.<>c__DisplayClass2_0.<Main>b__0(Options o)
   at CommandLine.ParserResultExtensions.WithParsed[T](ParserResult`1 result, Action`1 action)
   at PSXPackager.Program.Main(String[] args)

After adding some debug code, the paths appear as follows:

WSL/Direct

file:\wsl$\Ubuntu-18.04\home\enderwiggin\PSXPackager\PSXPackager\bin\Debug\net462\Resources\gameinfo.db

Mono

home/enderwiggin/PSXPackager/PSXPackager/bin/Debug/net462/Resources/gameinfo.db

So the path seems to be duplicated because there is no root slash, so it's being treated as a relative path.

RupertAvery commented 3 years ago

It turned out to be the path and the casing of "gameInfo.db". I've found the proper way to get the application path that works in Mono, Linux and Windows.

I've pushed an update, please get latest.