MCPcopy Create free account
hub / github.com/OpenZWave/open-zwave / FileRotate

Method FileRotate

cpp/src/platform/unix/FileOpsImpl.cpp:107–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105}
106
107bool FileOpsImpl::FileRotate
108(
109 const string _filename
110)
111{
112 int i = 1;
113 string newFile;
114 /* find a filename not used yet */
115 newFile = _filename;
116 newFile.append(".").append(intToString(i));
117 while (FileExists(newFile)) {
118 i++;
119 newFile = _filename;
120 newFile.append(".").append(intToString(i));
121 }
122 /* copy the file */
123 if (!FileCopy(_filename, newFile)) {
124 Log::Write(LogLevel_Warning, "File Rotate Failed: %s -> %s", _filename.c_str(), newFile.c_str());
125 return false;
126 }
127
128 /* remove the old file */
129 if ( remove(_filename.c_str())) {
130 Log::Write(LogLevel_Warning, "File Removal failed: %s", _filename.c_str());
131 return false;
132 }
133 return true;
134}
135
136
137bool FileOpsImpl::FileCopy

Callers

nothing calls this directly

Calls 2

WriteFunction · 0.85
c_strMethod · 0.45

Tested by

no test coverage detected