Clone
ixen <ixen@copyhandler.com>
committed
on 03 Jan 13
Create empty chcmd project (CH-43).
LoggerImprovements + 5 more
src/libchengine/TLocalFilesystem.cpp (+10 -0)
333 333
334 334                 return std::shared_ptr<TLocalFilesystemFind>(new TLocalFilesystemFind(pathDir, pathMask, m_spLog->GetLogFileData()));
335 335         }
336 336
337 337         IFilesystemFilePtr TLocalFilesystem::CreateFileObject(IFilesystemFile::EOpenMode eMode, const TSmartPath& pathFile, bool bNoBuffering, bool bProtectReadOnlyFiles)
338 338         {
339 339                 LOG_TRACE(m_spLog) << L"Creating file object for path " << pathFile << L" with no-buffering set to " << bNoBuffering << L" and protect-read-only set to " << bProtectReadOnlyFiles;
340 340                 return std::shared_ptr<TLocalFilesystemFile>(new TLocalFilesystemFile(eMode, pathFile, bNoBuffering, bProtectReadOnlyFiles, m_spLog->GetLogFileData()));
341 341         }
342 342
343 343         TSmartPath TLocalFilesystem::PrependPathExtensionIfNeeded(const TSmartPath& pathInput)
344 344         {
345 345                 const TSmartPath pathPrefix = PathFromString(L"\\\\?\\");
346 346
347 347                 if (pathInput.GetLength() >= 248 && !pathInput.StartsWith(pathPrefix))
348 348                         return pathPrefix + pathInput;
349 349
350 350                 return pathInput;
351 351         }
352 352
  353         TSmartPath TLocalFilesystem::StripPathExtensionIfNeeded(const TSmartPath& pathInput)
  354         {
  355                 const TSmartPath pathPrefix = PathFromString(L"\\\\?\\");
  356
  357                 if(pathInput.StartsWith(pathPrefix))
  358                         return PathFromString(pathInput.ToWString().Mid(pathPrefix.GetLength()).c_str());
  359
  360                 return pathInput;
  361         }
  362
353 363         TLocalFilesystem::EPathsRelation TLocalFilesystem::GetPathsRelation(const TSmartPath& pathFirst, const TSmartPath& pathSecond)
354 364         {
355 365                 if (pathFirst.IsEmpty())
356 366                         throw TCoreException(eErr_InvalidArgument, L"pathFirst", LOCATION);
357 367                 if(pathSecond.IsEmpty())
358 368                         throw TCoreException(eErr_InvalidArgument, L"pathSecond", LOCATION);
359 369
360 370                 LOG_DEBUG(m_spLog) << L"Trying to find relation between paths: " << pathFirst << L" and " << pathSecond;
361 371
362 372                 // get information about both paths
363 373                 UINT uiFirstDriveType = GetDriveData(pathFirst);
364 374                 UINT uiSecondDriveType = GetDriveData(pathSecond);
365 375
366 376                 LOG_TRACE(m_spLog) << L"Drive type for " << pathFirst << L" is " << uiFirstDriveType << L", drive type for " << pathSecond << L" is " << uiSecondDriveType;
367 377
368 378                 // what kind of relation...
369 379                 EPathsRelation eRelation = eRelation_Other;
370 380                 if (uiFirstDriveType == DRIVE_REMOTE || uiSecondDriveType == DRIVE_REMOTE)
371 381                         eRelation = eRelation_Network;
372 382                 else if (uiFirstDriveType == DRIVE_CDROM || uiSecondDriveType == DRIVE_CDROM)