| 1356 | |
| 1357 | |
| 1358 | void Archive::ConvertFileHeader(FileHeader *hd) |
| 1359 | { |
| 1360 | if (hd->HSType==HSYS_UNKNOWN) |
| 1361 | if (hd->Dir) |
| 1362 | hd->FileAttr=0x10; |
| 1363 | else |
| 1364 | hd->FileAttr=0x20; |
| 1365 | |
| 1366 | #ifdef _WIN_ALL |
| 1367 | if (hd->HSType==HSYS_UNIX) // Convert Unix, OS X and Android decomposed chracters to Windows precomposed. |
| 1368 | ConvertToPrecomposed(hd->FileName,ASIZE(hd->FileName)); |
| 1369 | #endif |
| 1370 | |
| 1371 | for (wchar *s=hd->FileName;*s!=0;s++) |
| 1372 | { |
| 1373 | #ifdef _UNIX |
| 1374 | // Backslash is the invalid character for Windows file headers, |
| 1375 | // but it can present in Unix file names extracted in Unix. |
| 1376 | if (*s=='\\' && Format==RARFMT50 && hd->HSType==HSYS_WINDOWS) |
| 1377 | *s='_'; |
| 1378 | #endif |
| 1379 | |
| 1380 | #if defined(_WIN_ALL) || defined(_EMX) |
| 1381 | // RAR 5.0 archives do not use '\' as path separator, so if we see it, |
| 1382 | // it means that it is a part of Unix file name, which we cannot |
| 1383 | // extract in Windows. |
| 1384 | if (*s=='\\' && Format==RARFMT50) |
| 1385 | *s='_'; |
| 1386 | |
| 1387 | // ':' in file names is allowed in Unix, but not in Windows. |
| 1388 | // Even worse, file data will be written to NTFS stream on NTFS, |
| 1389 | // so automatic name correction on file create error in extraction |
| 1390 | // routine does not work. In Windows and DOS versions we better |
| 1391 | // replace ':' now. |
| 1392 | if (*s==':') |
| 1393 | *s='_'; |
| 1394 | #endif |
| 1395 | |
| 1396 | // This code must be performed only after other path separator checks, |
| 1397 | // because it produces backslashes illegal for some of checks above. |
| 1398 | // Backslash is allowed in file names in Unix, but not in Windows. |
| 1399 | // Still, RAR 4.x uses backslashes as path separator even in Unix. |
| 1400 | // Forward slash is not allowed in both systems. In RAR 5.0 we use |
| 1401 | // the forward slash as universal path separator. |
| 1402 | if (*s=='/' || *s=='\\' && Format!=RARFMT50) |
| 1403 | *s=CPATHDIVIDER; |
| 1404 | } |
| 1405 | } |
| 1406 | |
| 1407 | |
| 1408 | int64 Archive::GetStartPos() |
nothing calls this directly
no test coverage detected