Files
revng-revng/lib/Storage/Path.cpp
T
Giacomo Vercesi 8c76e7d2ef Cleanup Storage classes
Due to the removal of `S3StorageClient`, simplify the infrastructure
under `/Storage/`:
* Move and rename `LocalStorageClient` to `StorageClient`, de-virtualize
  all of its methods
* Move and rename `LocalWritableFile`, `LocalReadableFile` to
  `WritableFile` and `ReadableFile`, de-vitualize all methods
* Drop the `Std{in,out}StorageClient`, make `FilePath` handle the
  stdin/stdout logic
* Remove `setStorageCredentials` from `PipelineManager`
2025-05-07 16:42:34 +02:00

39 lines
983 B
C++

/// \file Path.cpp
//
// This file is distributed under the MIT License. See LICENSE.md for details.
//
#include "llvm/Support/FileSystem.h"
#include "revng/Storage/Path.h"
#include "revng/Storage/StorageClient.h"
#include "revng/Support/Error.h"
namespace {
// TODO: unix-specific, will not work on Windows
revng::StorageClient LocalClient("/");
std::string normalizeLocalPath(llvm::StringRef Path) {
llvm::SmallString<256> PathCopy(Path);
revng::cantFail(llvm::sys::fs::make_absolute(PathCopy));
llvm::sys::path::remove_dots(PathCopy, true);
llvm::StringRef Result(PathCopy.substr(1)); // Remove leading '/'
return Result.str();
}
} // namespace
namespace revng {
DirectoryPath DirectoryPath::fromLocalStorage(llvm::StringRef Path) {
return revng::DirectoryPath{ &LocalClient, normalizeLocalPath(Path) };
}
FilePath FilePath::fromLocalStorage(llvm::StringRef Path) {
return revng::FilePath{ &LocalClient, normalizeLocalPath(Path) };
}
} // namespace revng