aboutsummaryrefslogtreecommitdiff
path: root/src/cmd_fsops.cc
diff options
context:
space:
mode:
authorYour Name <you@example.com>2022-01-16 21:32:01 -0500
committerYour Name <you@example.com>2022-01-16 21:32:01 -0500
commitd0e356d09e30a11c1e072415a5088f829d5c0a04 (patch)
tree1e64d37b9b424cd74c30ad4c8225828c7a76874e /src/cmd_fsops.cc
parent3f78a7e1647ba94129236bd2bf4fc855c109628a (diff)
downloaddmtool-d0e356d09e30a11c1e072415a5088f829d5c0a04.tar.gz
dmtool-d0e356d09e30a11c1e072415a5088f829d5c0a04.tar.bz2
dmtool-d0e356d09e30a11c1e072415a5088f829d5c0a04.zip
Worked on features
Diffstat (limited to 'src/cmd_fsops.cc')
-rw-r--r--src/cmd_fsops.cc87
1 files changed, 0 insertions, 87 deletions
diff --git a/src/cmd_fsops.cc b/src/cmd_fsops.cc
deleted file mode 100644
index ac4bdef..0000000
--- a/src/cmd_fsops.cc
+++ /dev/null
@@ -1,87 +0,0 @@
-#include "cmd.h"
-#include "utils.h"
-#include "entry.h"
-#include <filesystem>
-#include <sstream>
-
-namespace fs = std::filesystem;
-
-namespace cmd {
- std::string list(const fs::path& p) {
- std::stringstream text;
- if(p.empty()) {
- // Print read-only dirs
- for(std::string name : getVirtDirs()) {
- text << name << "/ (read only)" << std::endl;
- }
- }
- fs::path truePath = getTruePath(p);
- if(fs::directory_entry(truePath).is_regular_file()) {
- text << utils::instantiate<entry::Entry>(truePath)->getText() << std::endl;
- }
- else if(fs::directory_entry(truePath).is_directory()) {
- for(fs::directory_entry de : fs::directory_iterator(truePath)) {
- if(de.path().filename().string()[0] != '.') {
- if(de.is_directory()) {
- text << de.path().filename().string() << "/" << std::endl;
- } else {
- text << de.path().stem().string() << std::endl;
- }
- }
- }
- }
- else {
- text << "Unknown path " << p << std::endl;
- }
- return text.str();
- }
-
- std::string list(std::vector<std::string> args) {
- std::stringstream text;
- if(args.empty()) {
- text << list("");
- } else {
- for(std::string dir : args) {
- text << list(dir);
- }
- }
- return text.str();
- }
-
- std::string mkdir(std::vector<std::string> args) {
- for(std::string s : args) {
- fs::create_directories(getTruePath(s));
- }
- return "";
- }
-
- void cp(fs::path src, fs::path dest) {
- if(fs::directory_entry(src).is_regular_file()) {
- utils::saveJson(utils::instantiate<entry::Entry>(src)->serialize(), dest);
- } else {
- mkdir({dest});
- for(fs::directory_entry de : fs::directory_iterator(src)) {
- cp(de.path(), dest / de.path().filename());
- }
- }
- }
-
- std::string cp(std::vector<std::string> args) {
- // Operate by intantiating and saving
- // We do recursive!
- cp(getTruePath(args[0]), getTruePath(args[1]));
- return "";
- }
-
- std::string mv(std::vector<std::string> args) {
- fs::rename(getTruePath(args[0]), getTruePath(args[1]));
- return "";
- }
-
- std::string rm(std::vector<std::string> args) {
- for(std::string s : args) {
- fs::remove_all(getTruePath(s));
- }
- return "";
- }
-}