mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-15 04:34:56 +00:00
feature: fileio now uses Global.FilePathPrefix as its directory
All read wirtes now use the current working essentials directory. This resolves issues between 3 series, 4 series, and VC-4
This commit is contained in:
@@ -21,35 +21,37 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="fileName"></param>
|
/// <param name="fileName"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static FileInfo[] GetFiles(string fileName)
|
public static FileInfo[] GetFiles(string fileName)
|
||||||
{
|
{
|
||||||
DirectoryInfo dirInfo = new DirectoryInfo(Path.GetDirectoryName(fileName));
|
string fullFilePath = Global.FilePathPrefix + "/" + fileName;
|
||||||
var files = dirInfo.GetFiles(Path.GetFileName(fileName));
|
DirectoryInfo dirInfo = new DirectoryInfo(Path.GetDirectoryName(fullFilePath));
|
||||||
Debug.Console(0, "FileIO found: {0}, {1}", files.Count(), fileName);
|
var files = dirInfo.GetFiles(Path.GetFileName(fullFilePath));
|
||||||
if (files.Count() > 0)
|
Debug.Console(0, "FileIO found: {0}, {1}", files.Count(), fullFilePath);
|
||||||
{
|
if (files.Count() > 0)
|
||||||
return files;
|
{
|
||||||
}
|
return files;
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
return null;
|
{
|
||||||
}
|
return null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static FileInfo GetFile(string fileName)
|
public static FileInfo GetFile(string fileName)
|
||||||
{
|
{
|
||||||
DirectoryInfo dirInfo = new DirectoryInfo(Path.GetDirectoryName(fileName));
|
string fullFilePath = Global.FilePathPrefix + "/" + fileName;
|
||||||
var files = dirInfo.GetFiles(Path.GetFileName(fileName));
|
DirectoryInfo dirInfo = new DirectoryInfo(Path.GetDirectoryName(fullFilePath));
|
||||||
Debug.Console(0, "FileIO found: {0}, {1}", files.Count(), fileName);
|
var files = dirInfo.GetFiles(Path.GetFileName(fullFilePath));
|
||||||
if (files.Count() > 0)
|
Debug.Console(0, "FileIO found: {0}, {1}", files.Count(), fullFilePath);
|
||||||
{
|
if (files.Count() > 0)
|
||||||
return files.FirstOrDefault();
|
{
|
||||||
}
|
return files.FirstOrDefault();
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
return null;
|
{
|
||||||
}
|
return null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -202,7 +204,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
public static void WriteDataToFile(string data, string filePath)
|
public static void WriteDataToFile(string data, string filePath)
|
||||||
{
|
{
|
||||||
Thread _WriteFileThread;
|
Thread _WriteFileThread;
|
||||||
_WriteFileThread = new Thread((O) => _WriteFileMethod(data, filePath), null, Thread.eThreadStartOptions.CreateSuspended);
|
_WriteFileThread = new Thread((O) => _WriteFileMethod(data, Global.FilePathPrefix + "/" + filePath), null, Thread.eThreadStartOptions.CreateSuspended);
|
||||||
_WriteFileThread.Priority = Thread.eThreadPriority.LowestPriority;
|
_WriteFileThread.Priority = Thread.eThreadPriority.LowestPriority;
|
||||||
_WriteFileThread.Start();
|
_WriteFileThread.Start();
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "New WriteFile Thread");
|
Debug.Console(0, Debug.ErrorLogLevel.Notice, "New WriteFile Thread");
|
||||||
@@ -217,7 +219,8 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
if (fileLock.TryEnter())
|
if (fileLock.TryEnter())
|
||||||
{
|
{
|
||||||
using (StreamWriter sw = new StreamWriter(filePath))
|
|
||||||
|
using (StreamWriter sw = new StreamWriter(filePath))
|
||||||
{
|
{
|
||||||
sw.Write(data);
|
sw.Write(data);
|
||||||
sw.Flush();
|
sw.Flush();
|
||||||
|
|||||||
Reference in New Issue
Block a user