MCPcopy Create free account
hub / github.com/Universal-Team/Universal-Updater / renameFile

Method renameFile

source/utils/scriptUtils.cpp:136–157  ·  view source on GitHub ↗

Rename / Move a file. */

Source from the content-addressed store, hash-verified

134
135/* Rename / Move a file. */
136Result ScriptUtils::renameFile(const std::string &oldName, const std::string &newName, bool isARG) {
137 Result ret = NONE;
138 if (access(oldName.c_str(), F_OK) != 0) return MOVE_ERROR;
139
140 std::string old, _new;
141 old = std::regex_replace(oldName, std::regex("%ARCHIVE_DEFAULT%"), config->archPath());
142 old = std::regex_replace(old, std::regex("%3DSX%/(.*)\\.(.*)"), config->_3dsxPath() + (config->_3dsxInFolder() ? "/$1/$1.$2" : "/$1.$2"));
143 old = std::regex_replace(old, std::regex("%3DSX%"), config->_3dsxPath());
144 old = std::regex_replace(old, std::regex("%NDS%"), config->ndsPath());
145 old = std::regex_replace(old, std::regex("%FIRM%"), config->firmPath());
146
147 _new = std::regex_replace(newName, std::regex("%ARCHIVE_DEFAULT%"), config->archPath());
148 _new = std::regex_replace(_new, std::regex("%3DSX%/(.*)\\.(.*)"), config->_3dsxPath() + (config->_3dsxInFolder() ? "/$1/$1.$2" : "/$1.$2"));
149 _new = std::regex_replace(_new, std::regex("%3DSX%"), config->_3dsxPath());
150 _new = std::regex_replace(_new, std::regex("%NDS%"), config->ndsPath());
151 _new = std::regex_replace(_new, std::regex("%FIRM%"), config->firmPath());
152
153 /* TODO: Kinda avoid that? */
154 makeDirs(_new.c_str());
155 rename(old.c_str(), _new.c_str());
156 return ret;
157}
158
159/* Download from GitHub Release. */
160Result ScriptUtils::downloadRelease(const std::string &repo, const std::string &file, const std::string &output, bool includePrereleases, const std::string &message, bool isARG) {

Callers

nothing calls this directly

Calls 6

makeDirsFunction · 0.85
archPathMethod · 0.80
_3dsxPathMethod · 0.80
_3dsxInFolderMethod · 0.80
ndsPathMethod · 0.80
firmPathMethod · 0.80

Tested by

no test coverage detected