Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if STORAGE~=nil then
- return;
- end
- STORAGE = {};
- STORAGE.PATH = "D:/store/";
- function STORAGE:RepositoryExists(key)
- local info = nwn.GetFileInfo(self.PATH..key);
- if info == nil then
- return false;
- else
- return info.isFolder;
- end
- end
- function STORAGE:GetAllFilesInRepo(key)
- if not self:RepositoryExists(key) then
- return 0;
- end
- local files = {};
- local folder = self.PATH..key.."/";
- local filter = folder.."*.uti";
- local file, attrib = nwn.GetFirstFile(filter);
- while file do
- if file ~= "." and file ~= ".." then
- table.insert(files,folder..file);
- file, attrib = nwn.GetNextFile();
- end
- end
- nwscript.STORAGE = files;
- return #files;
- end
- function STORAGE:EmptyRepo(key)
- local folder = self.PATH.."/"..key;
- if not self:RepositoryExists(key) then
- if nwn.CreateDirectory(folder) then
- return folder.."/";
- else
- return "";
- end
- end
- local files = {};
- local files = {};
- folder = self.PATH..key.."/";
- local filter = folder.."*.uti";
- local file, attrib = nwn.GetFirstFile(filter);
- while file do
- if file ~= "." and file ~= ".." then
- table.insert(files,folder..file);
- file, attrib = nwn.GetNextFile();
- end
- end
- local cnt = 0;
- for n=1,#files do
- nwn.DeleteFile(files[n]);
- end
- return folder;
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement