Skip to content

Commit

Permalink
Release v0 (#8)
Browse files Browse the repository at this point in the history
* 1st release working

* 1st release
  • Loading branch information
ujjwall-R authored Jul 1, 2023
1 parent f6886f1 commit 0203851
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/compile/main
.vscode
obj
obj
dreeAlias.sh
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ $(DIRECTORIES):

# Target to run the program
run: $(EXECUTABLE)
$(EXECUTABLE)
$(EXECUTABLE) $(ARGS)

# Clean target
clean:
rm -rf $(OBJDIR) $(EXECUTABLE)

2 changes: 2 additions & 0 deletions dree.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
script_dir="$(dirname "$0")"
make run -C "$script_dir" ARGS="$(pwd) $1"
3 changes: 3 additions & 0 deletions dump.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# #!/bin/bash
# make run -C /home/ujjwal/Desktop/crawlir ARGS="$(pwd) $1"

25 changes: 25 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,31 @@ Say no to bulky file managers with Dree.

**Important:** This project is a work in progress and is not intended for production use at this time. It is undergoing active development, and changes, improvements, and bug fixes are being made frequently.

# Installation[Linux]

To run the Directory Tree Visualizer project, follow these steps:

1. Ensure you have C++17 compiler and development environment set up on your linux or mac system
2. Clone the project repository to your local machine.

```shell
git clone https://github.com/ujjwall-R/Dree
cd Dree
```

Add path to `dree.sh` in `~/.bashrc` as:

```
alias dree='path/to/project/dree.sh'
```

## Run [example]

```
dree 3
```

# Development

## How to Run [Development]

Expand Down
8 changes: 4 additions & 4 deletions src/controller/DirectoryGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void DirectoryGraph::TraverseDirectoriesDFS(DirectoryNode *node, long long depth
}
}

void DirectoryGraph::PrintGraph(DirectoryNode *node, long long depth, long long currentDepth, bool isLastChild, long long mask)
void DirectoryGraph::PrintGraphDFS(DirectoryNode *node, long long depth, long long currentDepth, bool isLastChild, long long mask)
{
if (currentDepth == depth)
return;
Expand All @@ -62,11 +62,11 @@ void DirectoryGraph::PrintGraph(DirectoryNode *node, long long depth, long long
{
mask = mask | (1ll << (currentDepth + 1));
}
PrintGraph(child, depth, currentDepth + 1, i == node->children.size() - 1, mask);
PrintGraphDFS(child, depth, currentDepth + 1, i == node->children.size() - 1, mask);
}
}

void DirectoryGraph::PrintGraph(DirectoryNode *node, long long depth)
void DirectoryGraph::PrintGraphDFS(DirectoryNode *node, long long depth)
{
this->PrintGraph(node, depth, 0, true, 1);
this->PrintGraphDFS(node, depth, 0ll, true, 1ll);
}
4 changes: 2 additions & 2 deletions src/controller/DirectoryGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ class DirectoryGraph
{
public:
DirectoryNode *BuildGraph(const string &directoryName, long long depth);
void PrintGraph(DirectoryNode *node, long long depth);
void PrintGraphDFS(DirectoryNode *node, long long depth);

private:
bool isDirectory(const std::string &pathStr);
void TraverseDirectoriesDFS(DirectoryNode *node, long long depth, long long currentDepth = 0);
void PrintGraph(DirectoryNode *node, long long depth, long long currentDepth, bool isLastChild, long long mask);
void PrintGraphDFS(DirectoryNode *node, long long depth, long long currentDepth, bool isLastChild, long long mask);
};

#endif
22 changes: 18 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,26 @@

using namespace std;

int main()
int main(int argc, char *argv[])
{
long long depth = 3; // should not be more than 60
auto currentPath = filesystem::current_path();
if (argc != 3)
{
cout << "Missing args" << std::endl;
return 1;
}
string currentPath = argv[1];
filesystem::path directoryPath(currentPath);
int depth = stoi(argv[2]);

// TODO:add check to prevent overflow
if (depth >= 60)
{
cout << "mask overflow!!\n";
return 1;
}

DirectoryGraph builder;
auto root = builder.BuildGraph(currentPath, depth);
builder.PrintGraph(root, depth);
builder.PrintGraphDFS(root, depth);
return 0;
}

0 comments on commit 0203851

Please sign in to comment.