/************************************************************************* * UrBackup - Client/Server backup system * Copyright (C) 2011-2014 Martin Raiber * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . **************************************************************************/ #include #include #include "../vld.h" #include "CriticalSection.h" #include "types.h" #include "../stringtools.h" #include "log.h" #include "settings.h" #include "../Interface/Server.h" struct s_mapl { std::wstring value; _u32 lastmaptime; }; std::map mapbuffer; CriticalSection mapcs; std::wstring getOsDir(std::wstring input) { #ifdef _WIN32 for(size_t i=0;i::iterator i=mapbuffer.find(ts); if(i==mapbuffer.end() ) { mapcs.Leave(); Log("Could not find share \""+Server->ConvertToUTF8(ts)+"\"", LL_WARNING); return L""; } else { mapcs.Leave(); return getFileName(getOsDir(fn), i->second.value,append_urd, udir); } } void add_share_path(const std::wstring &name, const std::wstring &path) { s_mapl m; m.value=getOsDir(path); mapcs.Enter(); mapbuffer[name]=m; mapcs.Leave(); } void remove_share_path(const std::wstring &name) { mapcs.Enter(); std::map::iterator it=mapbuffer.find(name); if(it!=mapbuffer.end()) { mapbuffer.erase(it); } mapcs.Leave(); } std::vector get_maps(void) { std::vector ret; mapcs.Enter(); for(std::map::iterator it=mapbuffer.begin();it!=mapbuffer.end();++it) { ret.push_back(it->first); } mapcs.Leave(); return ret; }