| 250 | } |
| 251 | |
| 252 | int PreserveMetadataUtf8(const std::string& source, |
| 253 | const std::string& target) { |
| 254 | #ifdef _WIN32 |
| 255 | (void)source; |
| 256 | (void)target; |
| 257 | return 0; |
| 258 | #else |
| 259 | struct stat sourceStat; |
| 260 | if (stat(source.c_str(), &sourceStat) != 0) { |
| 261 | return -1; |
| 262 | } |
| 263 | if (chown(target.c_str(), sourceStat.st_uid, sourceStat.st_gid) != 0) { |
| 264 | return -1; |
| 265 | } |
| 266 | if (chmod(target.c_str(), sourceStat.st_mode & 07777) != 0) { |
| 267 | return -1; |
| 268 | } |
| 269 | return 0; |
| 270 | #endif |
| 271 | } |
| 272 | |
| 273 | int ReplaceFileUtf8(const std::string& source, const std::string& target) { |
| 274 | #ifdef _WIN32 |