From 08acf2b63b61a938c1c6ed746f4c8c7de6300f19 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 30 Jul 2012 17:11:22 +0200 Subject: [PATCH] Changed: #1440 Moved more metadata utility functions --HG-- branch : build_pipeline_v3 --- .../tools/pipeline/service/database_status.cpp | 16 +++------------- .../tools/pipeline/service/metadata_storage.cpp | 17 +++++++++++++++++ .../tools/pipeline/service/metadata_storage.h | 5 +++++ 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/code/nel/tools/pipeline/service/database_status.cpp b/code/nel/tools/pipeline/service/database_status.cpp index 8faa4ad72..573a393fe 100644 --- a/code/nel/tools/pipeline/service/database_status.cpp +++ b/code/nel/tools/pipeline/service/database_status.cpp @@ -46,16 +46,6 @@ using namespace NLMISC; namespace PIPELINE { -namespace { - -/// Create status file path -std::string getStatusFilePath(const std::string &path) -{ - return CWorkspaceStorage::getMetaFilePath(path, PIPELINE_DATABASE_STATUS_SUFFIX); -} - -} /* anonymous namespace */ - CDatabaseStatus::CDatabaseStatus() { //CFile::createDirectoryTree(g_WorkspaceDirectory + PIPELINE_DATABASE_STATUS_SUBDIR); @@ -71,7 +61,7 @@ bool CDatabaseStatus::getFileStatus(CFileStatus &fileStatus, const std::string & { bool seemsValid = false; std::string stdPath = unMacroPath(filePath); - std::string statusPath = getStatusFilePath(filePath); + std::string statusPath = CMetadataStorage::getStatusPath(filePath); m_StatusMutex.lock_shared(); if (CMetadataStorage::readStatus(fileStatus, statusPath)) { @@ -222,7 +212,7 @@ public: bool firstSeen = false; uint32 time = CTime::getSecondsSince1970(); uint32 fmdt = CFile::getFileModificationDate(FilePath); - std::string statusPath = getStatusFilePath(FilePath); // g_WorkspaceDirectory + PIPELINE_DATABASE_STATUS_SUBDIR + dropDatabaseDirectory(FilePath) + ".status"; + std::string statusPath = CMetadataStorage::getStatusPath(FilePath); // g_WorkspaceDirectory + PIPELINE_DATABASE_STATUS_SUBDIR + dropDatabaseDirectory(FilePath) + ".status"; StatusMutex->lock_shared(); bool statusFileExists = CMetadataStorage::readStatus(fs, statusPath); if (!statusFileExists) @@ -490,7 +480,7 @@ void updateDirectoryStatus(CDatabaseStatus* ds, CDatabaseStatusUpdater &updater, nldebug("Created '%s'", removedTagFile.c_str()); // Delete the status. - NLMISC::CFile::deleteFile(subPath); + CMetadataStorage::eraseStatus(subPath); nlinfo("Removed '%s'", subPath.c_str()); } } diff --git a/code/nel/tools/pipeline/service/metadata_storage.cpp b/code/nel/tools/pipeline/service/metadata_storage.cpp index fea9d0e12..61c02818b 100644 --- a/code/nel/tools/pipeline/service/metadata_storage.cpp +++ b/code/nel/tools/pipeline/service/metadata_storage.cpp @@ -43,6 +43,10 @@ using namespace std; namespace PIPELINE { +/////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////// + void CFileError::serial(NLMISC::IStream &stream) throw (NLMISC::EStream) { uint version = stream.serialVersion(1); @@ -82,6 +86,15 @@ void CProjectOutput::serial(NLMISC::IStream &stream) throw (NLMISC::EStream) stream.serialCont(FileOutputs); } +/////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////// + +std::string CMetadataStorage::getStatusPath(const std::string &file) +{ + return CWorkspaceStorage::getMetaFilePath(file, PIPELINE_DATABASE_STATUS_SUFFIX); +} + bool CMetadataStorage::readStatus(CFileStatus &status, const std::string &path) { if (!NLMISC::CFile::fileExists(path)) @@ -116,6 +129,10 @@ void CMetadataStorage::eraseStatus(const std::string &path) NLMISC::CFile::deleteFile(path); } +/////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////// + } /* namespace PIPELINE */ /* end of file */ diff --git a/code/nel/tools/pipeline/service/metadata_storage.h b/code/nel/tools/pipeline/service/metadata_storage.h index 6110d4b33..7826c4338 100644 --- a/code/nel/tools/pipeline/service/metadata_storage.h +++ b/code/nel/tools/pipeline/service/metadata_storage.h @@ -130,10 +130,15 @@ class CMetadataStorage public: /// Note: Use the functions provided by CDatabaseStatus for manipulating status files. + static std::string getStatusPath(const std::string &file); static bool readStatus(CFileStatus &status, const std::string &path); static void writeStatus(const CFileStatus &status, const std::string &path); static void eraseStatus(const std::string &path); + static bool readRemove(CFileRemove &remove, const std::string & path); + static void createRemove(const CFileRemove &remove, const std::string &path); // Remove cannot be modified after creation, only erased. + static void eraseRemove(const std::string &path); + }; /* class CMetadataStorage */ } /* namespace PIPELINE */