| 135 | |
| 136 | |
| 137 | bool FileOpsImpl::FileCopy |
| 138 | ( |
| 139 | const string _sourcefile, |
| 140 | const string _destfile |
| 141 | ) |
| 142 | { |
| 143 | |
| 144 | if (!FileExists(_sourcefile)) { |
| 145 | Log::Write(LogLevel_Warning, "Source File %s doesn't exist in FileCopy", _sourcefile.c_str()); |
| 146 | return false; |
| 147 | } |
| 148 | if (FileExists(_destfile)) { |
| 149 | Log::Write(LogLevel_Warning, "Destination File %s exists in FileCopy", _destfile.c_str()); |
| 150 | return false; |
| 151 | } |
| 152 | |
| 153 | /* make sure the Destination Folder Exists */ |
| 154 | if (!FolderExists(ozwdirname(_destfile))) { |
| 155 | Log::Write(LogLevel_Warning, "Destination Folder %s Doesn't Exist", ozwdirname(_destfile).c_str()); |
| 156 | return false; |
| 157 | } |
| 158 | |
| 159 | |
| 160 | std::ifstream in(_sourcefile.c_str(), ios_base::in | ios_base::binary); |
| 161 | std::ofstream out(_destfile.c_str(), ios_base::out | ios_base::binary); |
| 162 | char buf[COPY_BUF_SIZE]; |
| 163 | |
| 164 | do { |
| 165 | in.read(&buf[0], COPY_BUF_SIZE); |
| 166 | out.write(&buf[0], in.gcount()); |
| 167 | } while (in.gcount() > 0); |
| 168 | in.close(); |
| 169 | out.close(); |
| 170 | return true; |
| 171 | } |
| 172 | |
| 173 | bool FileOpsImpl::FolderCreate |
| 174 | ( |