diff --git a/Makefile b/Makefile index f52e8c2..40bacea 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ SRC += sdk/megabdb.cpp sdk/megaclient.cpp sdk/megacrypto.cpp OUT = $(TARGET) OBJ = $(patsubst %.cpp,%.o,$(patsubst %.c,%.o,$(SRC))) -.PHONY: +.PHONY: clean install # include directories @@ -45,3 +45,9 @@ $(OUT): $(OBJ) clean: rm -f $(OBJ) $(OUT) + +install: $(OUT) + mkdir -p /usr/share/doc/MegaFuse + cp FAQ.txt LICENSE.txt README.md megafuse.conf /usr/share/doc/MegaFuse/ + cp megafuse.service megafuse@.service /lib/systemd/system/ + cp $(OUT) /usr/bin/ diff --git a/inc/Config.h b/inc/Config.h index afa5703..388cc45 100644 --- a/inc/Config.h +++ b/inc/Config.h @@ -14,6 +14,7 @@ std::string PASSWORD; std::string APPKEY; std::string MOUNTPOINT; + std::string CACHEPATH; int fuseindex; private: Config(); diff --git a/megafuse.conf b/megafuse.conf index b7a640d..a86df22 100644 --- a/megafuse.conf +++ b/megafuse.conf @@ -13,3 +13,7 @@ #### you can specify a mountpoint here, only absolute paths are supported. #MOUNTPOINT = /tmp/s + +#### path for the cached files; /tmp is the default, change it if your /tmp is small + +CACHEPATH = /tmp diff --git a/src/Config.cpp b/src/Config.cpp index 3434de2..2b57390 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -40,7 +40,7 @@ bool Config::parseCommandLine(int argc, char**argv) configFile=optarg; cout <<"ss "< countEntriesInDir(CACHEPATH)) + CACHEPATH = getString("Specify a valid cache path (eg: /tmp): ",false); } Config::Config():APPKEY("MEGASDK"),fuseindex(-1),configFile("megafuse.conf") diff --git a/src/file_cache_row.cpp b/src/file_cache_row.cpp index 71c71c8..4d0e096 100644 --- a/src/file_cache_row.cpp +++ b/src/file_cache_row.cpp @@ -3,6 +3,7 @@ */ #include "file_cache_row.h" +#include "Config.h" #include #include #include @@ -12,8 +13,8 @@ file_cache_row::file_cache_row(): td(-1),status(INVALID),size(0),available_bytes(0),n_clients(0),startOffset(0),modified(false),handle(0) { - char filename[] = "/tmp/mega.XXXXXX"; - close (mkstemp(filename)); + std::string filename = Config::getInstance()->CACHEPATH + "/mega.XXXXXX"; + close (mkstemp(&filename[0])); localname = filename; printf("creato il file %s\n",localname.c_str()); }