Add ParrelSync and netcode
This commit is contained in:
31
Assets/ParrelSync/Editor/FileUtilities.cs
Normal file
31
Assets/ParrelSync/Editor/FileUtilities.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ParrelSync
|
||||
{
|
||||
public class FileUtilities
|
||||
{
|
||||
public static bool IsFileLocked(string path)
|
||||
{
|
||||
FileInfo file = new FileInfo(path);
|
||||
try
|
||||
{
|
||||
using (FileStream stream = file.Open(FileMode.Open, FileAccess.Read, FileShare.None))
|
||||
{
|
||||
stream.Close();
|
||||
}
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
//the file is unavailable because it is:
|
||||
//still being written to
|
||||
//or being processed by another thread
|
||||
//or does not exist (has already been processed)
|
||||
return true;
|
||||
}
|
||||
|
||||
//file is not locked
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user