| 123 | }; |
| 124 | |
| 125 | bool dPathCopy(const char *fromName, const char *toName, bool nooverwrite) |
| 126 | { |
| 127 | AssertFatal( fromName != NULL && toName != NULL, "dPathCopy - NULL file name" ); |
| 128 | |
| 129 | TempAlloc< TCHAR > from( dStrlen( fromName ) + 1 ); |
| 130 | TempAlloc< TCHAR > to( dStrlen( toName ) + 1 ); |
| 131 | |
| 132 | #ifdef UNICODE |
| 133 | convertUTF8toUTF16N( fromName, from, from.size ); |
| 134 | convertUTF8toUTF16N( toName, to, to.size ); |
| 135 | #else |
| 136 | dStrcpy( from, fromName, from.size ); |
| 137 | dStrcpy( to, toName, to.size ); |
| 138 | #endif |
| 139 | |
| 140 | backslash( from ); |
| 141 | backslash( to ); |
| 142 | |
| 143 | // Copy File |
| 144 | if (Platform::isFile(fromName)) |
| 145 | return CopyFile( from, to, nooverwrite ); |
| 146 | // Copy Path |
| 147 | else if (Platform::isDirectory(fromName)) |
| 148 | { |
| 149 | // If the destination path exists and we don't want to overwrite, return. |
| 150 | if ((Platform::isDirectory(toName) || Platform::isFile(toName)) && nooverwrite) |
| 151 | return false; |
| 152 | |
| 153 | Vector<StringTableEntry> directoryInfo; |
| 154 | Platform::dumpDirectories(fromName, directoryInfo, -1); |
| 155 | |
| 156 | Vector<Platform::FileInfo> fileInfo; |
| 157 | Platform::dumpPath(fromName, fileInfo); |
| 158 | |
| 159 | Platform::clearExcludedDirectories(); |
| 160 | |
| 161 | TempAlloc< char > tempBuf( to.size * 3 + MAX_PATH * 3 ); |
| 162 | |
| 163 | // Create all the directories. |
| 164 | for (S32 i = 0; i < directoryInfo.size(); i++) |
| 165 | { |
| 166 | const char* fromDir = directoryInfo[i]; |
| 167 | |
| 168 | char* toDir = tempBuf; |
| 169 | Platform::makeFullPathName(fromDir + dStrlen(fromName) + (dStricmp(fromDir, fromName) ? 1 : 0), tempBuf, tempBuf.size, toName); |
| 170 | if(*(toDir + dStrlen(toDir) - 1) != '/') |
| 171 | dStrcat(toDir, "/", tempBuf.size); |
| 172 | forwardslash(toDir); |
| 173 | |
| 174 | if (!Platform::createPath(toDir)) |
| 175 | { |
| 176 | //TODO: New directory should be deleted here. |
| 177 | return false; |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | TempAlloc< char > tempBuf1( from.size * 3 + MAX_PATH * 3 ); |
| 182 | #ifdef UNICODE |
no test coverage detected