| 81 | |
| 82 | #ifdef _WIN_ALL |
| 83 | void ExtractStreams(Archive &Arc,const wchar *FileName,bool TestMode) |
| 84 | { |
| 85 | wchar FullName[NM+2]; |
| 86 | if (FileName[0]!=0 && FileName[1]==0) |
| 87 | { |
| 88 | // Convert single character names like f:stream to .\f:stream to |
| 89 | // resolve the ambiguity with drive letters. |
| 90 | wcsncpyz(FullName,L".\\",ASIZE(FullName)); |
| 91 | wcsncatz(FullName,FileName,ASIZE(FullName)); |
| 92 | } |
| 93 | else |
| 94 | wcsncpyz(FullName,FileName,ASIZE(FullName)); |
| 95 | |
| 96 | wchar StreamName[NM]; |
| 97 | GetStreamNameNTFS(Arc,StreamName,ASIZE(StreamName)); |
| 98 | if (*StreamName!=':') |
| 99 | { |
| 100 | uiMsg(UIERROR_STREAMBROKEN,Arc.FileName,FileName); |
| 101 | ErrHandler.SetErrorCode(RARX_CRC); |
| 102 | return; |
| 103 | } |
| 104 | |
| 105 | if (TestMode) |
| 106 | { |
| 107 | File CurFile; |
| 108 | Arc.ReadSubData(NULL,&CurFile,true); |
| 109 | return; |
| 110 | } |
| 111 | |
| 112 | wcsncatz(FullName,StreamName,ASIZE(FullName)); |
| 113 | |
| 114 | FindData fd; |
| 115 | bool Found=FindFile::FastFind(FileName,&fd); |
| 116 | |
| 117 | if ((fd.FileAttr & FILE_ATTRIBUTE_READONLY)!=0) |
| 118 | SetFileAttr(FileName,fd.FileAttr & ~FILE_ATTRIBUTE_READONLY); |
| 119 | File CurFile; |
| 120 | if (CurFile.WCreate(FullName) && Arc.ReadSubData(NULL,&CurFile,false)) |
| 121 | CurFile.Close(); |
| 122 | File HostFile; |
| 123 | if (Found && HostFile.Open(FileName,FMF_OPENSHARED|FMF_UPDATE)) |
| 124 | SetFileTime(HostFile.GetHandle(),&fd.ftCreationTime,&fd.ftLastAccessTime, |
| 125 | &fd.ftLastWriteTime); |
| 126 | |
| 127 | // Restoring original file attributes. Important if file was read only |
| 128 | // or did not have "Archive" attribute |
| 129 | SetFileAttr(FileName,fd.FileAttr); |
| 130 | } |
| 131 | #endif |
| 132 | |
| 133 |
no test coverage detected