void SliceManager::_init() { BString dataPath; _formDataPath(dataPath); Directory::makeDirRecursive(dataPath.c_str()); BString indexPath; _formIndexPath(indexPath); Directory::makeDirRecursive(indexPath.c_str()); try { Directory dir(dataPath.c_str()); BString dataFileName; BString indexFileName; while (dir.next()) { if (dir.name()[0] == '.') continue; TSliceID sliceID = strtoul(dir.name(), NULL, 10); dataFileName.sprintfSet("%s/%u", dataPath.c_str(), sliceID); indexFileName.sprintfSet("%s/%u", indexPath.c_str(), sliceID); TSlicePtr slice(new Slice(sliceID, dataFileName, indexFileName)); if (sliceID >= _slices.size()) _slices.resize(sliceID + 1); _slices[sliceID] = slice; } return; } catch (Directory::Error &er) { log::Error::L("Can't open slice storage data path %s\n", dataPath.c_str()); } throw SliceError("Can't initialize sliceManager"); }
void SliceManager::_formIndexPath(BString &path) { path.sprintfSet("%s/index", _path.c_str()); }
void SliceManager::_formDataPath(BString &path) { path.sprintfSet("%s/data", _path.c_str()); }