Skip to content

Commit

Permalink
Masplund/less system calls (#255)
Browse files Browse the repository at this point in the history
* Convert to try open
* Add up to date test
  • Loading branch information
mwasplund authored Sep 8, 2024
1 parent 0ef073a commit a12f472
Show file tree
Hide file tree
Showing 16 changed files with 809 additions and 359 deletions.
7 changes: 5 additions & 2 deletions Source/Client/Core/Source/Build/FileSystemState.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,12 @@ namespace Soup::Core
// Load the write times for all files in the directory
// This optimization assumes that most files in a directory are relevant to the build
// and on windows it is a lot faster to iterate over the files instead of making individual calls
System::IFileSystem::Current().GetDirectoryFilesLastWriteTime(
if (!System::IFileSystem::Current().TryGetDirectoryFilesLastWriteTime(
directory,
callback);
callback))
{
Log::Info("Preload Directory Missing: {}", directory.ToString());
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,15 @@ namespace Soup::Core
const Path& localUserConfigFile,
LocalUserConfig& result)
{
// Verify the requested file exists
// Open the file to read from
Log::Diag("Load Local User Config: {}", localUserConfigFile.ToString());
if (!System::IFileSystem::Current().Exists(localUserConfigFile))
std::shared_ptr<System::IInputFile> file;
if (!System::IFileSystem::Current().TryOpenRead(localUserConfigFile, true, file))
{
Log::Warning("Local User Config file does not exist");
return false;
}

// Open the file to read from
auto file = System::IFileSystem::Current().OpenRead(localUserConfigFile, true);

// Read the contents of the local user config file
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,14 @@ namespace Soup::Core
OperationGraph& result,
FileSystemState& fileSystemState)
{
// Verify the requested file exists
if (!System::IFileSystem::Current().Exists(operationGraphFile))
// Open the file to read from
std::shared_ptr<System::IInputFile> file;
if (!System::IFileSystem::Current().TryOpenRead(operationGraphFile, true, file))
{
Log::Info("Operation graph file does not exist");
return false;
}

// Open the file to read from
auto file = System::IFileSystem::Current().OpenRead(operationGraphFile, true);

// Read the contents of the build state file
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,14 @@ namespace Soup::Core
OperationResults& result,
FileSystemState& fileSystemState)
{
// Verify the requested file exists
if (!System::IFileSystem::Current().Exists(operationResultsFile))
// Open the file to read from
std::shared_ptr<System::IInputFile> file;
if (!System::IFileSystem::Current().TryOpenRead(operationResultsFile, true, file))
{
Log::Info("Operation results file does not exist");
return false;
}

// Open the file to read from
auto file = System::IFileSystem::Current().OpenRead(operationResultsFile, true);

// Read the contents of the build state file
try
{
Expand Down
8 changes: 3 additions & 5 deletions Source/Client/Core/Source/PackageLock/PackageLockExtensions.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,15 @@ namespace Soup::Core
const Path& packageLockFile,
PackageLock& result)
{
// Verify the requested file exists
// Open the file to read from
Log::Diag("Load PackageLock: {}", packageLockFile.ToString());
if (!System::IFileSystem::Current().Exists(packageLockFile))
std::shared_ptr<System::IInputFile> file;
if (!System::IFileSystem::Current().TryOpenRead(packageLockFile, true, file))
{
Log::Info("PackageLock file does not exist");
return false;
}

// Open the file to read from
auto file = System::IFileSystem::Current().OpenRead(packageLockFile, true);

// Read the contents of the recipe file
try
{
Expand Down
8 changes: 3 additions & 5 deletions Source/Client/Core/Source/Recipe/RecipeExtensions.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,15 @@ namespace Soup::Core
const Path& recipeFile,
Recipe& result)
{
// Verify the requested file exists
// Open the file to read from
Log::Diag("Load Recipe: {}", recipeFile.ToString());
if (!System::IFileSystem::Current().Exists(recipeFile))
std::shared_ptr<System::IInputFile> file;
if (!System::IFileSystem::Current().TryOpenRead(recipeFile, true, file))
{
Log::Info("Recipe file does not exist.");
return false;
}

// Open the file to read from
auto file = System::IFileSystem::Current().OpenRead(recipeFile, true);

// Read the contents of the recipe file
try
{
Expand Down
8 changes: 3 additions & 5 deletions Source/Client/Core/Source/ValueTable/ValueTableManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,14 @@ namespace Soup::Core
const Path& valueTableFile,
ValueTable& result)
{
// Verify the requested file exists
if (!System::IFileSystem::Current().Exists(valueTableFile))
// Open the file to read from
std::shared_ptr<System::IInputFile> file;
if (!System::IFileSystem::Current().TryOpenRead(valueTableFile, true, file))
{
Log::Info("Value Table file does not exist");
return false;
}

// Open the file to read from
auto file = System::IFileSystem::Current().OpenRead(valueTableFile, true);

// Read the contents of the build state file
try
{
Expand Down
Loading

0 comments on commit a12f472

Please sign in to comment.