Skip to content

Commit

Permalink
Directio error output (#131)
Browse files Browse the repository at this point in the history
* Write the error message from linux on failures

* Create directory if it does not exist in direct io
  • Loading branch information
Ulimo authored Nov 17, 2023
1 parent 5b04aeb commit 6cc0b66
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ private static string GetErrorMessage(int errorCode)
public FileCacheUnixDirectWriter(string fileName, int sectorSize, FileCacheOptions fileCacheOptions)
{
this.alignment = sectorSize;

var directoryName = Path.GetDirectoryName(fileName);
if (directoryName != null && !Directory.Exists(directoryName))
{
Directory.CreateDirectory(directoryName);
}

// Check if the file already exists, if so delete it
if (File.Exists(fileName))
{
File.Delete(fileName);
}

this.fileDescriptor = open(fileName, O_RDWR | O_DIRECT | O_CREAT, S_IRUSR | S_IWUSR);
if (this.fileDescriptor == -1)
{
Expand Down

0 comments on commit 6cc0b66

Please sign in to comment.