Skip to content

Commit

Permalink
changed to new mountpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Pelanek committed Jun 13, 2024
1 parent 9f25ecf commit f3a5efc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
8 changes: 4 additions & 4 deletions examples/basicExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ int main() {
std::shared_ptr<telemetry::Directory> telemetryRootNode;
telemetryRootNode = telemetry::Directory::create();

// path to root dir, which has to exist before the program starts.
// The path is local to where the program is called from.
// The path to root dir is local to where the program is called from.
std::string fusePath = "fusedir";

// Linking root dir to the chosen directory on disk.
telemetry::appFs::AppFsFuse fuse = telemetry::appFs::AppFsFuse(telemetryRootNode, fusePath, true, false);
// If the fourth argument is true it means the directory on disk doesn't need to
// exist before starting program.
telemetry::appFs::AppFsFuse fuse = telemetry::appFs::AppFsFuse(telemetryRootNode, fusePath, true, true);
fuse.start();
// The filesystem is still just empty.
// /
Expand Down Expand Up @@ -91,7 +92,6 @@ int main() {
// │ └─ time
// └─ time

// Don't forget to create directory named fusedir
// Waiting for ctrl+c. In the meantime you can open another terminal and
// navigate to the newly linked directory. Just reading the new time file
// should print the time elapsed in seconds since the start of the program.
Expand Down
9 changes: 5 additions & 4 deletions examples/holderExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <telemetry.hpp>
#include <appFs.hpp>

// Object that collects it's own telemetry or owns
// telemetry files or directories.
class IOwnTelemetryFiles {
public:
void configTelemetry(const std::shared_ptr<telemetry::Directory>& rootDir) {
Expand Down Expand Up @@ -39,13 +41,12 @@ int main() {

std::string fusePath = "fusedir";

telemetry::appFs::AppFsFuse fuse = telemetry::appFs::AppFsFuse(telemetryRootNode, fusePath);
telemetry::appFs::AppFsFuse fuse = telemetry::appFs::AppFsFuse(telemetryRootNode, fusePath, true, true);
fuse.start();

// Object that collects it's own telemetry or owns
// telemetry files or directories.
// The files callbacks get disabled when the telemetry holder
// is destroyed.
// is destroyed and if the files and dirs don't have another reference
// elsewhere they get destroyed too.
IOwnTelemetryFiles object;

// Configuration of telemetry inside of the object.
Expand Down
19 changes: 10 additions & 9 deletions examples/utilsExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
void traverseDir(std::shared_ptr<telemetry::Directory>& dir, int depth) {
// Using utils to check if a directory is a root directory
if(telemetry::utils::isRootDirectory(dir->getFullPath())) {
std::cout << "start\n";
std::cout << "root\n";
}

// looping through files and dirs in directory
Expand All @@ -40,7 +40,8 @@ void traverseDir(std::shared_ptr<telemetry::Directory>& dir, int depth) {
try {
std::cout << telemetry::contentToString(file->read());
} catch(std::exception& ex) {
std::cout << ex.what() << "\n";
// File::read operation not supported
// std::cout << ex.what() << "\n";
}
}
}
Expand All @@ -53,7 +54,7 @@ int main() {

std::string fusePath = "fusedir";

telemetry::appFs::AppFsFuse fuse = telemetry::appFs::AppFsFuse(telemetryRootNode, fusePath);
telemetry::appFs::AppFsFuse fuse = telemetry::appFs::AppFsFuse(telemetryRootNode, fusePath, true, true);
fuse.start();

// Let's create a more complex dir structure
Expand All @@ -68,15 +69,15 @@ int main() {
auto dir2 = dir1->addDir("dir2");
auto dir3 = dir1->addDir("dir3");

const int nFiles = 5;
for(int index = 0; index < nFiles; index++) {
auto file = dir2->addFile("file" + std::to_string(index + 4), emptyFileOps);
}
auto file4 = dir2->addFile("file4", emptyFileOps);
auto file5 = dir2->addFile("file5", emptyFileOps);
auto file6 = dir2->addFile("file6", emptyFileOps);
auto file7 = dir2->addFile("file7", emptyFileOps);

auto file9 = dir3->addFile("file9", emptyFileOps);
auto file8 = dir3->addFile("file8", emptyFileOps);

// And now traverse the directory with the use of telemetry utils
traverseDir(telemetryRootNode, 0);
traverseDir(telemetryRootNode, 1);

// Utils can also give you a node from path
auto node = telemetry::utils::getNodeFromPath(telemetryRootNode, "/dir1/dir2/file5");
Expand Down

0 comments on commit f3a5efc

Please sign in to comment.