v4.7.0.2
- Fixed a file locked exception
This commit is contained in:
parent
39e5ba06ad
commit
c8c3354379
4 changed files with 23 additions and 29 deletions
|
@ -4,7 +4,7 @@
|
|||
<TargetFramework>net7.0-windows</TargetFramework>
|
||||
<UseWindowsForms>True</UseWindowsForms>
|
||||
<ApplicationIcon>Resources\ini.ico</ApplicationIcon>
|
||||
<Version>4.7.0.1</Version>
|
||||
<Version>4.7.0.2</Version>
|
||||
<Copyright>2021, pointfeev (https://github.com/pointfeev)</Copyright>
|
||||
<Company>CreamInstaller</Company>
|
||||
<Product>Automatic DLC Unlocker Installer & Configuration Generator</Product>
|
||||
|
|
|
@ -64,35 +64,31 @@ internal sealed class ProgramSelection
|
|||
if (Platform is Platform.Steam or Platform.Paradox)
|
||||
{
|
||||
directory.GetCreamApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string config);
|
||||
if (api32.IsFilePathLocked() || api32_o.IsFilePathLocked() || api64.IsFilePathLocked() || api64_o.IsFilePathLocked()
|
||||
|| config.IsFilePathLocked())
|
||||
if (api32.FileLocked() || api32_o.FileLocked() || api64.FileLocked() || api64_o.FileLocked() || config.FileLocked())
|
||||
return true;
|
||||
directory.GetSmokeApiComponents(out api32, out api32_o, out api64, out api64_o, out string old_config, out config, out string old_log,
|
||||
out string log, out string cache);
|
||||
if (api32.IsFilePathLocked() || api32_o.IsFilePathLocked() || api64.IsFilePathLocked() || api64_o.IsFilePathLocked()
|
||||
|| old_config.IsFilePathLocked() || config.IsFilePathLocked() || old_log.IsFilePathLocked() || log.IsFilePathLocked()
|
||||
|| cache.IsFilePathLocked())
|
||||
if (api32.FileLocked() || api32_o.FileLocked() || api64.FileLocked() || api64_o.FileLocked() || old_config.FileLocked()
|
||||
|| config.FileLocked() || old_log.FileLocked() || log.FileLocked() || cache.FileLocked())
|
||||
return true;
|
||||
}
|
||||
if (Platform is Platform.Epic or Platform.Paradox)
|
||||
{
|
||||
directory.GetScreamApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string config,
|
||||
out string log);
|
||||
if (api32.IsFilePathLocked() || api32_o.IsFilePathLocked() || api64.IsFilePathLocked() || api64_o.IsFilePathLocked()
|
||||
|| config.IsFilePathLocked() || log.IsFilePathLocked())
|
||||
if (api32.FileLocked() || api32_o.FileLocked() || api64.FileLocked() || api64_o.FileLocked() || config.FileLocked() || log.FileLocked())
|
||||
return true;
|
||||
}
|
||||
if (Platform is Platform.Ubisoft)
|
||||
{
|
||||
directory.GetUplayR1Components(out string api32, out string api32_o, out string api64, out string api64_o, out string config,
|
||||
out string log);
|
||||
if (api32.IsFilePathLocked() || api32_o.IsFilePathLocked() || api64.IsFilePathLocked() || api64_o.IsFilePathLocked()
|
||||
|| config.IsFilePathLocked() || log.IsFilePathLocked())
|
||||
if (api32.FileLocked() || api32_o.FileLocked() || api64.FileLocked() || api64_o.FileLocked() || config.FileLocked() || log.FileLocked())
|
||||
return true;
|
||||
directory.GetUplayR2Components(out string old_api32, out string old_api64, out api32, out api32_o, out api64, out api64_o, out config,
|
||||
out log);
|
||||
if (old_api32.IsFilePathLocked() || old_api64.IsFilePathLocked() || api32.IsFilePathLocked() || api32_o.IsFilePathLocked()
|
||||
|| api64.IsFilePathLocked() || api64_o.IsFilePathLocked() || config.IsFilePathLocked() || log.IsFilePathLocked())
|
||||
if (old_api32.FileLocked() || old_api64.FileLocked() || api32.FileLocked() || api32_o.FileLocked() || api64.FileLocked()
|
||||
|| api64_o.FileLocked() || config.FileLocked() || log.FileLocked())
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -474,23 +474,6 @@ internal static class Resources
|
|||
}
|
||||
}
|
||||
|
||||
internal static bool IsFilePathLocked(this string filePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Open(filePath, FileMode.Open, FileAccess.ReadWrite, FileShare.None).Close();
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode), DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
|
||||
private static extern bool GetBinaryType(string lpApplicationName, out BinaryType lpBinaryType);
|
||||
|
||||
|
|
|
@ -11,6 +11,21 @@ namespace CreamInstaller.Utility;
|
|||
|
||||
internal static class SafeIO
|
||||
{
|
||||
internal static bool FileLocked(this string filePath)
|
||||
{
|
||||
if (!FileExists(filePath))
|
||||
return false;
|
||||
try
|
||||
{
|
||||
File.Open(filePath, FileMode.Open, FileAccess.ReadWrite, FileShare.None).Close();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
internal static bool DirectoryExists(this string directoryPath, bool crucial = false, Form form = null)
|
||||
{
|
||||
while (!Program.Canceled)
|
||||
|
|
Loading…
Reference in a new issue