!29551 Change data() to c_str() when getting char* from string

Merge pull request !29551 from luoyang/issues
This commit is contained in:
i-robot 2022-01-26 07:22:59 +00:00 committed by Gitee
commit 86281309ca
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
45 changed files with 72 additions and 72 deletions

View File

@ -169,7 +169,7 @@ Status JiebaTokenizer::AddDictChar(const std::vector<char> &file_path) {
Status JiebaTokenizer::ParserFile(const std::string &file_path,
std::vector<std::pair<std::string, int64_t>> *const user_dict) {
RETURN_UNEXPECTED_IF_NULL(user_dict);
auto realpath = FileUtils::GetRealPath(file_path.data());
auto realpath = FileUtils::GetRealPath(file_path.c_str());
if (!realpath.has_value()) {
std::string err_msg = "Get real path failed, path: " + file_path;
LOG_AND_RETURN_STATUS_SYNTAX_ERROR(err_msg);

View File

@ -1009,7 +1009,7 @@ Status GenerateWaveTable(std::shared_ptr<Tensor> *output, const DataType &type,
Status ReadWaveFile(const std::string &wav_file_dir, std::vector<float> *waveform_vec, int32_t *sample_rate) {
RETURN_UNEXPECTED_IF_NULL(waveform_vec);
RETURN_UNEXPECTED_IF_NULL(sample_rate);
auto wav_realpath = FileUtils::GetRealPath(wav_file_dir.data());
auto wav_realpath = FileUtils::GetRealPath(wav_file_dir.c_str());
if (!wav_realpath.has_value()) {
LOG_AND_RETURN_STATUS_SYNTAX_ERROR("Invalid file path, get real path failed: " + wav_file_dir);
}

View File

@ -123,7 +123,7 @@ Status CacheServerHW::GetNumaNodeInfo() {
numa_id_t numa_node = static_cast<numa_id_t>(strtol(node_dir.data() + strlen(kNodeName), nullptr, kDecimal));
Path f = p / kCpuList;
auto realpath = FileUtils::GetRealPath(f.ToString().data());
auto realpath = FileUtils::GetRealPath(f.ToString().c_str());
if (!realpath.has_value()) {
MS_LOG(ERROR) << "Get real path failed, path=" << f.ToString();
RETURN_STATUS_UNEXPECTED("Get real path failed, path=" + f.ToString());

View File

@ -58,7 +58,7 @@ Status CelebAOp::ParseAttrFile() {
TaskManager::FindMe()->Post();
Path folder_path(folder_path_);
auto realpath = FileUtils::GetRealPath((folder_path / "list_attr_celeba.txt").ToString().data());
auto realpath = FileUtils::GetRealPath((folder_path / "list_attr_celeba.txt").ToString().c_str());
if (!realpath.has_value()) {
MS_LOG(ERROR) << "Invalid file path, " << (folder_path / "list_attr_celeba.txt").ToString() << " does not exist.";
RETURN_STATUS_UNEXPECTED("Invalid file path, " + (folder_path / "list_attr_celeba.txt").ToString() +

View File

@ -107,7 +107,7 @@ void CityscapesOp::Print(std::ostream &out, bool show_all) const {
}
Status CityscapesOp::PrepareData() {
auto real_dataset_dir = FileUtils::GetRealPath(dataset_dir_.data());
auto real_dataset_dir = FileUtils::GetRealPath(dataset_dir_.c_str());
if (!real_dataset_dir.has_value()) {
MS_LOG(ERROR) << "Invalid file path, Cityscapes Dataset dir: " << dataset_dir_ << " does not exist.";
RETURN_STATUS_UNEXPECTED("Invalid file path, Cityscapes Dataset dir: " + dataset_dir_ + " does not exist.");

View File

@ -82,7 +82,7 @@ Status ClueOp::GetValue(const nlohmann::json &js, std::vector<std::string> key_c
}
Status ClueOp::LoadFile(const std::string &file, int64_t start_offset, int64_t end_offset, int32_t worker_id) {
auto realpath = FileUtils::GetRealPath(file.data());
auto realpath = FileUtils::GetRealPath(file.c_str());
if (!realpath.has_value()) {
std::string err_msg = "Invalid file path, " + file + " does not exist.";
LOG_AND_RETURN_STATUS_SYNTAX_ERROR(err_msg);
@ -230,7 +230,7 @@ Status ClueOp::CalculateNumRowsPerShard() {
}
int64_t CountTotalRowsPerFile(const std::string &file) {
auto realpath = FileUtils::GetRealPath(file.data());
auto realpath = FileUtils::GetRealPath(file.c_str());
if (!realpath.has_value()) {
MS_LOG(ERROR) << "Invalid file, " << file << " does not exist.";
return 0;

View File

@ -132,7 +132,7 @@ Status CMUArcticOp::ReadAudio(const std::string &audio_dir, std::shared_ptr<Tens
}
Status CMUArcticOp::PrepareData() {
auto realpath = FileUtils::GetRealPath(folder_path_.data());
auto realpath = FileUtils::GetRealPath(folder_path_.c_str());
if (!realpath.has_value()) {
MS_LOG(ERROR) << "Invalid file path, CMUArctic Dataset dir: " << folder_path_ << " does not exist.";
RETURN_STATUS_UNEXPECTED("Invalid file path, CMUArctic Dataset dir: " + folder_path_ + " does not exist.");

View File

@ -78,7 +78,7 @@ Status CocoOp::LoadTensorRow(row_id_type row_id, TensorRow *trow) {
RETURN_UNEXPECTED_IF_NULL(trow);
std::string image_id = image_ids_[row_id];
std::shared_ptr<Tensor> image;
auto real_path = FileUtils::GetRealPath(image_folder_path_.data());
auto real_path = FileUtils::GetRealPath(image_folder_path_.c_str());
if (!real_path.has_value()) {
RETURN_STATUS_UNEXPECTED("Invalid file path, COCO dataset image folder: " + image_folder_path_ +
" does not exist.");
@ -313,7 +313,7 @@ Status CocoOp::SearchNodeInJson(const nlohmann::json &input_tree, std::string no
Status CocoOp::PrepareData() {
nlohmann::json js;
try {
auto realpath = FileUtils::GetRealPath(annotation_path_.data());
auto realpath = FileUtils::GetRealPath(annotation_path_.c_str());
if (!realpath.has_value()) {
std::string err_msg = "Invalid file path, Coco Dataset annotation file: " + annotation_path_ + " does not exist.";
LOG_AND_RETURN_STATUS_SYNTAX_ERROR(err_msg);

View File

@ -115,7 +115,7 @@ Status CoNLL2000Op::Load(const std::vector<std::string> &word, const std::vector
}
Status CoNLL2000Op::LoadFile(const std::string &file, int64_t start_offset, int64_t end_offset, int32_t worker_id) {
auto realpath = FileUtils::GetRealPath(file.data());
auto realpath = FileUtils::GetRealPath(file.c_str());
if (!realpath.has_value()) {
MS_LOG(ERROR) << "Invalid file path, " << DatasetName() << " dataset dir: " << file << " does not exist.";
RETURN_STATUS_UNEXPECTED("Invalid file path, " + DatasetName() + " dataset dir: " + file + " does not exist.");

View File

@ -469,7 +469,7 @@ Status CsvOp::LoadFile(const std::string &file, int64_t start_offset, int64_t en
csv_parser.SetStartOffset(start_offset);
csv_parser.SetEndOffset(end_offset);
auto realpath = FileUtils::GetRealPath(file.data());
auto realpath = FileUtils::GetRealPath(file.c_str());
if (!realpath.has_value()) {
MS_LOG(ERROR) << "Invalid file path, " << file << " does not exist.";
RETURN_STATUS_UNEXPECTED("Invalid file path, " + file + " does not exist.");
@ -612,7 +612,7 @@ int64_t CsvOp::CountTotalRows(const std::string &file) {
return 0;
}
auto realpath = FileUtils::GetRealPath(file.data());
auto realpath = FileUtils::GetRealPath(file.c_str());
if (!realpath.has_value()) {
MS_LOG(ERROR) << "Invalid file path, csv file: " << file << " does not exist.";
return 0;
@ -716,7 +716,7 @@ Status CsvOp::ColMapAnalyse(const std::string &csv_file_name) {
if (column_name_list_.empty()) {
// Actually we only deal with the first file, because the column name set in other files must remain the same
if (!check_flag_) {
auto realpath = FileUtils::GetRealPath(csv_file_name.data());
auto realpath = FileUtils::GetRealPath(csv_file_name.c_str());
if (!realpath.has_value()) {
std::string err_msg = "Invalid file path, csv file: " + csv_file_name + " does not exist.";
MS_LOG(ERROR) << err_msg;
@ -774,7 +774,7 @@ bool CsvOp::ColumnNameValidate() {
std::string match_file;
for (auto &csv_file : csv_files_list_) {
auto realpath = FileUtils::GetRealPath(csv_file.data());
auto realpath = FileUtils::GetRealPath(csv_file.c_str());
if (!realpath.has_value()) {
MS_LOG(ERROR) << "Invalid file path, csv file: " << csv_file << " does not exist.";
return false;

View File

@ -158,7 +158,7 @@ Status DIV2KOp::GetDIV2KLRDirRealName(const std::string &hr_dir_key, const std::
Status DIV2KOp::GetDIV2KDataByUsage() {
const std::string kExtension = ".png";
auto real_dataset_dir = FileUtils::GetRealPath(dataset_dir_.data());
auto real_dataset_dir = FileUtils::GetRealPath(dataset_dir_.c_str());
if (!real_dataset_dir.has_value()) {
MS_LOG(ERROR) << "Invalid file path, div2k dataset dir: " << dataset_dir_ << " does not exist.";
RETURN_STATUS_UNEXPECTED("Invalid file path, div2k dataset dir: " + dataset_dir_ + " does not exist.");

View File

@ -57,7 +57,7 @@ Status EMnistOp::WalkAllFiles() {
const std::string lbl_ext = "-labels-idx1-ubyte";
const std::string train_prefix = "-train";
const std::string test_prefix = "-test";
auto realpath = FileUtils::GetRealPath(folder_path_.data());
auto realpath = FileUtils::GetRealPath(folder_path_.c_str());
CHECK_FAIL_RETURN_UNEXPECTED(realpath.has_value(), "Invalid file path, " + folder_path_ + " does not exist.");
Path dir(realpath.value());
auto dir_it = Path::DirIterator::OpenDirectory(&dir);

View File

@ -52,7 +52,7 @@ void EnWik9Op::Print(std::ostream &out, bool show_all) const {
}
Status EnWik9Op::LoadFile(const std::string &file, int64_t start_offset, int64_t end_offset, int32_t worker_id) {
auto realpath = FileUtils::GetRealPath(file.data());
auto realpath = FileUtils::GetRealPath(file.c_str());
if (!realpath.has_value()) {
MS_LOG(ERROR) << "Invalid file path, " << file << " does not exist.";
RETURN_STATUS_UNEXPECTED("Invalid file path, " + file + " does not exist.");
@ -93,7 +93,7 @@ Status EnWik9Op::LoadFile(const std::string &file, int64_t start_offset, int64_t
}
int64_t EnWik9Op::CountTotalRows(const std::string &file) {
auto realpath = FileUtils::GetRealPath(file.data());
auto realpath = FileUtils::GetRealPath(file.c_str());
if (!realpath.has_value()) {
MS_LOG(ERROR) << "Invalid file, " << file << " does not exist.";
return 0;

View File

@ -75,7 +75,7 @@ void FlickrOp::Print(std::ostream &out, bool show_all) const {
}
Status FlickrOp::PrepareData() {
auto real_file_path = FileUtils::GetRealPath(file_path_.data());
auto real_file_path = FileUtils::GetRealPath(file_path_.c_str());
if (!real_file_path.has_value()) {
MS_LOG(ERROR) << "Invalid file path, " << file_path_ << " does not exist.";
RETURN_STATUS_UNEXPECTED("Invalid file path, " + file_path_ + " does not exist.");
@ -147,7 +147,7 @@ Status FlickrOp::PrepareData() {
// Optimization: Could take in a tensor
// This function does not return status because we want to just skip bad input, not crash
Status FlickrOp::CheckImageType(const std::string &file_name, bool *valid) {
auto real_file_name = FileUtils::GetRealPath(file_name.data());
auto real_file_name = FileUtils::GetRealPath(file_name.c_str());
if (!real_file_name.has_value()) {
MS_LOG(ERROR) << "Invalid file path, flickr dataset file: " << file_name << " does not exist.";
RETURN_STATUS_UNEXPECTED("Invalid file path, flickr dataset file: " + file_name + " does not exist.");

View File

@ -277,7 +277,7 @@ Status GTZANOp::ReadAudio(const std::string &audio_dir, std::shared_ptr<Tensor>
}
Status GTZANOp::PrepareData() {
auto realpath = FileUtils::GetRealPath(folder_path_.data());
auto realpath = FileUtils::GetRealPath(folder_path_.c_str());
if (!realpath.has_value()) {
MS_LOG(ERROR) << "Invalid file path, GTZAN Dataset dir: " << folder_path_ << " does not exist.";
RETURN_STATUS_UNEXPECTED("Invalid file path, GTZAN Dataset dir: " + folder_path_ + " does not exist.");

View File

@ -48,7 +48,7 @@ Status IMDBOp::PrepareData() {
}
std::vector<std::string> label_list = {"pos", "neg"};
// get abs path for folder_path_
auto realpath = FileUtils::GetRealPath(folder_path_.data());
auto realpath = FileUtils::GetRealPath(folder_path_.c_str());
if (!realpath.has_value()) {
MS_LOG(ERROR) << "Invalid file path, imdb dataset dir: " << folder_path_ << " does not exist.";
RETURN_STATUS_UNEXPECTED("Invalid file path, imdb dataset dir: " + folder_path_ + " does not exist.");
@ -142,7 +142,7 @@ Status IMDBOp::GetDataByUsage(const std::string &folder, const std::string &labe
Status IMDBOp::CountRows(const std::string &path, const std::string &usage, int64_t *num_rows) {
RETURN_UNEXPECTED_IF_NULL(num_rows);
// get abs path for folder_path_
auto abs_path = FileUtils::GetRealPath(path.data());
auto abs_path = FileUtils::GetRealPath(path.c_str());
if (!abs_path.has_value()) {
MS_LOG(ERROR) << "Invalid file path, imdb dataset dir: " << path << " does not exist.";
RETURN_STATUS_UNEXPECTED("Invalid file path, imdb dataset dir: " + path + " does not exist.");

View File

@ -447,7 +447,7 @@ std::string IWSLTOp::GenerateIWSLT2017XMLFileName(Path dir, const std::string &s
Status IWSLTOp::GetFiles() {
std::vector<std::string> src_path_list;
std::vector<std::string> target_path_list;
auto real_dataset_dir = FileUtils::GetRealPath(dataset_dir_.data());
auto real_dataset_dir = FileUtils::GetRealPath(dataset_dir_.c_str());
CHECK_FAIL_RETURN_UNEXPECTED(real_dataset_dir.has_value(), "Get real path failed: " + dataset_dir_);
Path root_dir(real_dataset_dir.value());

View File

@ -139,7 +139,7 @@ Status LibriTTSOp::ReadAudio(const std::string &audio_dir, std::shared_ptr<Tenso
}
Status LibriTTSOp::PrepareData() {
auto realpath = FileUtils::GetRealPath(dataset_dir_.data());
auto realpath = FileUtils::GetRealPath(dataset_dir_.c_str());
if (!realpath.has_value()) {
MS_LOG(ERROR) << "Invalid file path, LibriTTS dataset dir: " << dataset_dir_ << " does not exist.";
RETURN_STATUS_UNEXPECTED("Invalid file path, LibriTTS dataset dir: " + dataset_dir_ + " does not exist.");

View File

@ -36,7 +36,7 @@ LJSpeechOp::LJSpeechOp(const std::string &file_dir, int32_t num_workers, int32_t
data_schema_(std::move(data_schema)) {}
Status LJSpeechOp::PrepareData() {
auto real_path = FileUtils::GetRealPath(folder_path_.data());
auto real_path = FileUtils::GetRealPath(folder_path_.c_str());
if (!real_path.has_value()) {
RETURN_STATUS_UNEXPECTED("Invalid file path, LJSpeech Dataset folder: " + folder_path_ + " does not exist.");
}
@ -116,7 +116,7 @@ void LJSpeechOp::Print(std::ostream &out, bool show_all) const {
}
Status LJSpeechOp::CountTotalRows(const std::string &dir, int64_t *count) {
auto real_path = FileUtils::GetRealPath(dir.data());
auto real_path = FileUtils::GetRealPath(dir.c_str());
if (!real_path.has_value()) {
RETURN_STATUS_UNEXPECTED("Invalid file, " + dir + " does not exist.");
}

View File

@ -119,7 +119,7 @@ Status ManifestOp::GetClassIds(std::map<int32_t, std::vector<int64_t>> *cls_ids)
// {"source": "/path/to/image1.jpg", "usage":"train", annotation": ...}
// {"source": "/path/to/image2.jpg", "usage":"eval", "annotation": ...}
Status ManifestOp::PrepareData() {
auto realpath = FileUtils::GetRealPath(file_.data());
auto realpath = FileUtils::GetRealPath(file_.c_str());
if (!realpath.has_value()) {
MS_LOG(ERROR) << "Invalid file path, " << file_ << " does not exist.";
RETURN_STATUS_UNEXPECTED("Invalid file path, " + file_ + " does not exist.");
@ -194,7 +194,7 @@ Status ManifestOp::PrepareData() {
// Only support JPEG/PNG/GIF/BMP
Status ManifestOp::CheckImageType(const std::string &file_name, bool *valid) {
auto realpath = FileUtils::GetRealPath(file_name.data());
auto realpath = FileUtils::GetRealPath(file_name.c_str());
if (!realpath.has_value()) {
MS_LOG(ERROR) << "Invalid file path, " << file_name << " does not exist.";
RETURN_STATUS_UNEXPECTED("Invalid file path, " + file_name + " does not exist.");

View File

@ -68,7 +68,7 @@ Status Multi30kOp::LoadTensor(const std::string &line, TensorRow *out_row, size_
}
Status Multi30kOp::LoadFile(const std::string &file_en, int64_t start_offset, int64_t end_offset, int32_t worker_id) {
auto realpath_en = FileUtils::GetRealPath(file_en.data());
auto realpath_en = FileUtils::GetRealPath(file_en.c_str());
if (!realpath_en.has_value()) {
MS_LOG(ERROR) << "Invalid file path, " << DatasetName() + " Dataset file: " << file_en << " does not exist.";
RETURN_STATUS_UNEXPECTED("Invalid file path, " + DatasetName() + " Dataset file: " + file_en + " does not exist.");
@ -84,7 +84,7 @@ Status Multi30kOp::LoadFile(const std::string &file_en, int64_t start_offset, in
Path BaseName(basename);
Path path_de = parent_path / BaseName;
std::string file_de = path_de.ToString();
auto realpath_de = FileUtils::GetRealPath(file_de.data());
auto realpath_de = FileUtils::GetRealPath(file_de.c_str());
if (!realpath_de.has_value()) {
MS_LOG(ERROR) << "Invalid file path, " << DatasetName() + " Dataset file: " << file_de << " does not exist.";
RETURN_STATUS_UNEXPECTED("Invalid file path, " + DatasetName() + " Dataset file: " + file_de + " does not exist.");

View File

@ -337,7 +337,7 @@ Status PhotoTourOp::GetPhotoTourDataTensor(uint32_t index, std::shared_ptr<Tenso
Status PhotoTourOp::PrepareData() {
chosen_dataset_folder_path_ = (Path(dataset_dir_) / Path(name_)).ToString();
train_ = kTrain.at(usage_);
auto real_folder_path = FileUtils::GetRealPath(chosen_dataset_folder_path_.data());
auto real_folder_path = FileUtils::GetRealPath(chosen_dataset_folder_path_.c_str());
CHECK_FAIL_RETURN_UNEXPECTED(real_folder_path.has_value(), chosen_dataset_folder_path_ + " does not exist.");
std::vector<cv::String> file_names;

View File

@ -253,7 +253,7 @@ Status Places365Op::GetPlaces365DataTensor(uint32_t index, std::shared_ptr<Tenso
}
Status Places365Op::PrepareData() {
auto real_folder_path = FileUtils::GetRealPath(root_.data());
auto real_folder_path = FileUtils::GetRealPath(root_.c_str());
CHECK_FAIL_RETURN_UNEXPECTED(real_folder_path.has_value(), "Invalid file path, " + root_ + " does not exist.");
RETURN_IF_NOT_OK(LoadCategories((Path(real_folder_path.value()) / Path(kCategoriesMeta)).ToString()));

View File

@ -142,7 +142,7 @@ Status QMnistOp::WalkAllFiles() {
const std::string test_prefix = "qmnist-test";
const std::string nist_prefix = "xnist";
auto real_folder_path = FileUtils::GetRealPath(folder_path_.data());
auto real_folder_path = FileUtils::GetRealPath(folder_path_.c_str());
CHECK_FAIL_RETURN_UNEXPECTED(real_folder_path.has_value(),
"Invalid QMnist folder, " + folder_path_ + " does not exist or permission denied!");
Path root_dir(real_folder_path.value());

View File

@ -52,7 +52,7 @@ void SemeionOp::Print(std::ostream &out, bool show_all) const {
}
Status SemeionOp::PrepareData() {
auto real_path = FileUtils::GetRealPath(dataset_dir_.data());
auto real_path = FileUtils::GetRealPath(dataset_dir_.c_str());
if (!real_path.has_value()) {
RETURN_STATUS_UNEXPECTED("Invalid file path, Semeion Dataset folder: " + dataset_dir_ + " does not exist.");
}

View File

@ -50,7 +50,7 @@ Status SpeechCommandsOp::PrepareData() {
// Get file lists according to usage.
// When usage == "train", need to get all filenames then subtract files of usage: "test" and "valid".
std::set<std::string> selected_files;
auto real_dataset_dir = FileUtils::GetRealPath(dataset_dir_.data());
auto real_dataset_dir = FileUtils::GetRealPath(dataset_dir_.c_str());
if (!real_dataset_dir.has_value()) {
MS_LOG(ERROR) << "Get real path failed, path=" << dataset_dir_;
RETURN_STATUS_UNEXPECTED("Get real path failed, path=" + dataset_dir_);
@ -191,7 +191,7 @@ Status SpeechCommandsOp::GetFileInfo(const std::string &file_path, std::string *
Status SpeechCommandsOp::CountTotalRows(int64_t *num_rows) {
RETURN_UNEXPECTED_IF_NULL(num_rows);
if (all_wave_files.size() == 0) {
auto real_path = FileUtils::GetRealPath(dataset_dir_.data());
auto real_path = FileUtils::GetRealPath(dataset_dir_.c_str());
if (!real_path.has_value()) {
MS_LOG(ERROR) << "Get real path failed, path=" << dataset_dir_;
RETURN_STATUS_UNEXPECTED("Get real path failed, path=" + dataset_dir_);

View File

@ -93,7 +93,7 @@ void STL10Op::Print(std::ostream &out, bool show_all) const {
}
Status STL10Op::WalkAllFiles() {
auto real_dataset_dir = FileUtils::GetRealPath(folder_path_.data());
auto real_dataset_dir = FileUtils::GetRealPath(folder_path_.c_str());
CHECK_FAIL_RETURN_UNEXPECTED(real_dataset_dir.has_value(),
"Invalid file, get real path failed, path: " + folder_path_);
Path root_dir(real_dataset_dir.value());

View File

@ -78,7 +78,7 @@ Status TextFileOp::LoadTensor(const std::string &line, TensorRow *out_row) {
}
Status TextFileOp::LoadFile(const std::string &file, int64_t start_offset, int64_t end_offset, int32_t worker_id) {
auto realpath = FileUtils::GetRealPath(file.data());
auto realpath = FileUtils::GetRealPath(file.c_str());
if (!realpath.has_value()) {
MS_LOG(ERROR) << "Invalid file path, " << file << " does not exist.";
RETURN_STATUS_UNEXPECTED("Invalid file path, " + file + " does not exist.");
@ -168,7 +168,7 @@ Status TextFileOp::FillIOBlockQueue(const std::vector<int64_t> &i_keys) {
}
int64_t TextFileOp::CountTotalRows(const std::string &file) {
auto realpath = FileUtils::GetRealPath(file.data());
auto realpath = FileUtils::GetRealPath(file.c_str());
if (!realpath.has_value()) {
MS_LOG(ERROR) << "Invalid file, " << file << " does not exist.";
return 0;

View File

@ -42,7 +42,7 @@ namespace dataset {
const int64_t kTFRecordFileLimit = 0x140000000;
bool TFReaderOp::ValidateFirstRowCrc(const std::string &filename) {
auto realpath = FileUtils::GetRealPath(filename.data());
auto realpath = FileUtils::GetRealPath(filename.c_str());
if (!realpath.has_value()) {
MS_LOG(ERROR) << "Invalid file path, " << filename << " does not exist.";
return false;
@ -265,7 +265,7 @@ Status TFReaderOp::FillIOBlockNoShuffle() {
// Reads a tf_file file and loads the data into multiple TensorRows.
Status TFReaderOp::LoadFile(const std::string &filename, int64_t start_offset, int64_t end_offset, int32_t worker_id) {
auto realpath = FileUtils::GetRealPath(filename.data());
auto realpath = FileUtils::GetRealPath(filename.c_str());
if (!realpath.has_value()) {
MS_LOG(ERROR) << "Invalid file path, " << filename << " does not exist.";
RETURN_STATUS_UNEXPECTED("Invalid file path, " + filename + " does not exist.");
@ -553,7 +553,7 @@ Status TFReaderOp::LoadIntList(const ColDescriptor &current_col, const dataengin
}
Status TFReaderOp::CreateSchema(const std::string tf_file, std::vector<std::string> columns_to_load) {
auto realpath = FileUtils::GetRealPath(tf_file.data());
auto realpath = FileUtils::GetRealPath(tf_file.c_str());
if (!realpath.has_value()) {
MS_LOG(ERROR) << "Invalid file path, " << tf_file << " does not exist.";
RETURN_STATUS_UNEXPECTED("Invalid file path, " + tf_file + " does not exist.");
@ -691,7 +691,7 @@ Status TFReaderOp::CountTotalRows(int64_t *out_total_rows, const std::vector<std
int64_t TFReaderOp::CountTotalRowsSectioned(const std::vector<std::string> &filenames, int64_t begin, int64_t end) {
int64_t rows_read = 0;
for (int i = begin; i < end; i++) {
auto realpath = FileUtils::GetRealPath(filenames[i].data());
auto realpath = FileUtils::GetRealPath(filenames[i].c_str());
if (!realpath.has_value()) {
MS_LOG(ERROR) << "Invalid file path, " << filenames[i] << " does not exist.";
continue;

View File

@ -113,7 +113,7 @@ Status UDPOSOp::Load(const std::vector<std::string> &word, const std::vector<std
}
Status UDPOSOp::LoadFile(const std::string &file, int64_t start_offset, int64_t end_offset, int32_t worker_id) {
auto realpath = FileUtils::GetRealPath(file.data());
auto realpath = FileUtils::GetRealPath(file.c_str());
if (!realpath.has_value()) {
MS_LOG(ERROR) << "Invalid file path, " + DatasetName() + " dataset dir: " << file << " does not exist.";
RETURN_STATUS_UNEXPECTED("Invalid file path, " + DatasetName() + " dataset dir: " + file + " does not exist.");

View File

@ -123,7 +123,7 @@ int64_t USPSOp::CountRows(const std::string &data_file) {
}
Status USPSOp::GetFiles() {
auto real_dataset_dir = FileUtils::GetRealPath(dataset_dir_.data());
auto real_dataset_dir = FileUtils::GetRealPath(dataset_dir_.c_str());
CHECK_FAIL_RETURN_UNEXPECTED(real_dataset_dir.has_value(),
"Invalid file path, USPS dataset dir: " + dataset_dir_ + " does not exist.");
Path root_dir(real_dataset_dir.value());

View File

@ -116,7 +116,7 @@ Status VOCOp::ParseImageIds() {
image_sets_file = folder_path_ + std::string(kImageSetsMain) + usage_ + std::string(kImageSetsExtension);
}
auto realpath = FileUtils::GetRealPath(image_sets_file.data());
auto realpath = FileUtils::GetRealPath(image_sets_file.c_str());
if (!realpath.has_value()) {
MS_LOG(ERROR) << "Invalid file path, " << image_sets_file << " does not exist.";
RETURN_STATUS_UNEXPECTED("Invalid file path, " + image_sets_file + " does not exist.");

View File

@ -57,7 +57,7 @@ WIDERFaceOp::WIDERFaceOp(const std::string &folder_path, const std::string &usag
data_schema_(std::move(data_schema)) {}
Status WIDERFaceOp::PrepareData() {
auto realpath = FileUtils::GetRealPath(folder_path_.data());
auto realpath = FileUtils::GetRealPath(folder_path_.c_str());
if (!realpath.has_value()) {
MS_LOG(ERROR) << "Invalid file path, WIDERFace dataset dir: " << folder_path_ << " does not exist.";
RETURN_STATUS_UNEXPECTED("Invalid file path, WIDERFace dataset dir: " + folder_path_ + " does not exist.");

View File

@ -47,7 +47,7 @@ YesNoOp::YesNoOp(const std::string &file_dir, int32_t num_workers, int32_t queue
data_schema_(std::move(data_schema)) {}
Status YesNoOp::PrepareData() {
auto realpath = FileUtils::GetRealPath(dataset_dir_.data());
auto realpath = FileUtils::GetRealPath(dataset_dir_.c_str());
if (!realpath.has_value()) {
MS_LOG(ERROR) << "Invalid file path, " << dataset_dir_ << " does not exist.";
RETURN_STATUS_UNEXPECTED("Invalid file path, " + dataset_dir_ + " does not exist.");

View File

@ -53,7 +53,7 @@ GraphSharedMemory::~GraphSharedMemory() {
Status GraphSharedMemory::CreateSharedMemory() {
if (memory_key_ == -1) {
// ftok to generate unique key
auto realpath = FileUtils::GetRealPath(mr_file_.data());
auto realpath = FileUtils::GetRealPath(mr_file_.c_str());
CHECK_FAIL_RETURN_UNEXPECTED(realpath.has_value(), "Get real path failed, path=" + mr_file_);
memory_key_ = ftok(common::SafeCStr(realpath.value()), kGnnSharedMemoryId);
CHECK_FAIL_RETURN_UNEXPECTED(memory_key_ != -1, "Failed to get key of shared memory. file_name:" + mr_file_);

View File

@ -97,7 +97,7 @@ Status CelebANode::GetDatasetSize(const std::shared_ptr<DatasetSizeGetter> &size
std::string line;
Path folder_path(dataset_dir_);
auto realpath = FileUtils::GetRealPath((folder_path / "list_attr_celeba.txt").ToString().data());
auto realpath = FileUtils::GetRealPath((folder_path / "list_attr_celeba.txt").ToString().c_str());
if (!realpath.has_value()) {
MS_LOG(ERROR) << "Invalid file, get real path failed, path=" << (folder_path / "list_attr_celeba.txt").ToString();
RETURN_STATUS_UNEXPECTED("Invalid file, get real path failed, path=" +
@ -137,7 +137,7 @@ Status CelebANode::GetDatasetSize(const std::shared_ptr<DatasetSizeGetter> &size
}
}
if (!partition_file.is_open()) {
auto realpath_eval = FileUtils::GetRealPath((folder_path / "list_eval_partition.txt").ToString().data());
auto realpath_eval = FileUtils::GetRealPath((folder_path / "list_eval_partition.txt").ToString().c_str());
if (!realpath_eval.has_value()) {
MS_LOG(ERROR) << "Invalid file, get real path failed, path="
<< (folder_path / "list_eval_partition.txt").ToString();

View File

@ -63,7 +63,7 @@ Status Serdes::SaveJSONToFile(nlohmann::json json_string, const std::string &fil
if (!dir.has_value()) {
dir = ".";
}
auto realpath = FileUtils::GetRealPath(dir.value().data());
auto realpath = FileUtils::GetRealPath(dir.value().c_str());
if (!realpath.has_value()) {
MS_LOG(ERROR) << "Invalid file, get real path failed, path=" << file_name;
RETURN_STATUS_UNEXPECTED("Invalid file, get real path failed, path=" + file_name);

View File

@ -87,7 +87,7 @@ Status SentencePieceTokenizerOp::Compute(const std::shared_ptr<Tensor> &input, s
}
Status SentencePieceTokenizerOp::GetModelRealPath(const std::string &model_path, const std::string &filename) {
auto realpath = FileUtils::GetRealPath(model_path.data());
auto realpath = FileUtils::GetRealPath(model_path.c_str());
if (!realpath.has_value()) {
RETURN_STATUS_UNEXPECTED(
"SentencePieceTokenizer: Sentence piece model path is not existed or permission denied. Model path: " +

View File

@ -91,7 +91,7 @@ Status SentencePieceVocab::SaveModel(const std::shared_ptr<SentencePieceVocab> *
if (vocab == nullptr) {
RETURN_STATUS_UNEXPECTED("SentencePieceVocab::SaveModel: input vocab can not be null");
}
auto realpath = FileUtils::GetRealPath(path.data());
auto realpath = FileUtils::GetRealPath(path.c_str());
if (!realpath.has_value()) {
RETURN_STATUS_UNEXPECTED("Get real path failed, path=" + path);
}

View File

@ -168,7 +168,7 @@ Status Vocab::BuildFromFileCpp(const std::string &path, const std::string &delim
RETURN_STATUS_UNEXPECTED("Vocab::BuildFromFileCpp: input vocab can not be null");
}
// Validate parameters
auto realpath = FileUtils::GetRealPath(path.data());
auto realpath = FileUtils::GetRealPath(path.c_str());
CHECK_FAIL_RETURN_UNEXPECTED(realpath.has_value(), "Get real path failed, path=" + path);
CHECK_FAIL_RETURN_UNEXPECTED(
@ -241,7 +241,7 @@ Status Vocab::BuildFromFile(const std::string &path, const std::string &delimite
WordIdType word_id = prepend_special ? static_cast<WordIdType>(special_tokens.size()) : 0;
std::unordered_map<WordType, WordIdType> word2id;
auto realpath = FileUtils::GetRealPath(path.data());
auto realpath = FileUtils::GetRealPath(path.c_str());
if (!realpath.has_value()) {
RETURN_STATUS_UNEXPECTED("Get real path failed, path=" + path);
}

View File

@ -83,7 +83,7 @@ Status GetParentDir(const std::string &path, std::shared_ptr<std::string> *pd_pt
prefix_path = ".";
}
auto realpath = FileUtils::GetRealPath(prefix_path.value().data());
auto realpath = FileUtils::GetRealPath(prefix_path.value().c_str());
CHECK_FAIL_RETURN_UNEXPECTED(
realpath.has_value(), "Invalid file, failed to get the parent dir of mindrecord file. Please check file: " + path);

View File

@ -169,7 +169,7 @@ Status ShardIndexGenerator::CheckDatabase(const std::string &shard_address, sqli
dir = ".";
}
auto realpath = FileUtils::GetRealPath(dir.value().data());
auto realpath = FileUtils::GetRealPath(dir.value().c_str());
CHECK_FAIL_RETURN_UNEXPECTED(
realpath.has_value(),
"Invalid file, failed to get the realpath of mindrecord files. Please check file: " + shard_address);
@ -504,7 +504,7 @@ Status ShardIndexGenerator::ExecuteTransaction(const int &shard_no, sqlite3 *db,
// Add index data to database
std::string shard_address = shard_header_.GetShardAddressByID(shard_no);
auto realpath = FileUtils::GetRealPath(shard_address.data());
auto realpath = FileUtils::GetRealPath(shard_address.c_str());
CHECK_FAIL_RETURN_UNEXPECTED(
realpath.has_value(),
"Invalid file, failed to get the realpath of mindrecord files. Please check file path: " + shard_address);

View File

@ -197,7 +197,7 @@ Status ShardReader::Open() {
dir = ".";
}
auto realpath = FileUtils::GetRealPath(dir.value().data());
auto realpath = FileUtils::GetRealPath(dir.value().c_str());
CHECK_FAIL_RETURN_UNEXPECTED(
realpath.has_value(), "Invalid file, failed to get the realpath of mindrecord files. Please check file: " + file);
@ -230,7 +230,7 @@ Status ShardReader::Open(int n_consumer) {
dir = ".";
}
auto realpath = FileUtils::GetRealPath(dir.value().data());
auto realpath = FileUtils::GetRealPath(dir.value().c_str());
CHECK_FAIL_RETURN_UNEXPECTED(
realpath.has_value(),
"Invalid file, failed to get the realpath of mindrecord files. Please check file: " + file);
@ -438,7 +438,7 @@ Status ShardReader::ReadAllRowsInShard(int shard_id, const std::string &sql, con
MS_LOG(INFO) << "Succeed to get " << labels.size() << " records from shard " << std::to_string(shard_id) << " index.";
std::string file_name = file_paths_[shard_id];
auto realpath = FileUtils::GetRealPath(file_name.data());
auto realpath = FileUtils::GetRealPath(file_name.c_str());
if (!realpath.has_value()) {
sqlite3_free(errmsg);
sqlite3_close(db);
@ -763,7 +763,7 @@ Status ShardReader::GetLabelsFromBinaryFile(int shard_id, const std::vector<std:
std::shared_ptr<std::vector<json>> *labels_ptr) {
RETURN_UNEXPECTED_IF_NULL(labels_ptr);
std::string file_name = file_paths_[shard_id];
auto realpath = FileUtils::GetRealPath(file_name.data());
auto realpath = FileUtils::GetRealPath(file_name.c_str());
CHECK_FAIL_RETURN_UNEXPECTED(
realpath.has_value(),
"Invalid file, failed to get the realpath of mindrecord files. Please check file: " + file_name);

View File

@ -54,7 +54,7 @@ Status ShardWriter::GetFullPathFromFileName(const std::vector<std::string> &path
dir = ".";
}
auto realpath = FileUtils::GetRealPath(dir.value().data());
auto realpath = FileUtils::GetRealPath(dir.value().c_str());
CHECK_FAIL_RETURN_UNEXPECTED(
realpath.has_value(),
"Invalid dir, failed to get the realpath of mindrecord file dir. Please check path: " + dir.value());
@ -77,7 +77,7 @@ Status ShardWriter::OpenDataFiles(bool append, bool overwrite) {
dir = ".";
}
auto realpath = FileUtils::GetRealPath(dir.value().data());
auto realpath = FileUtils::GetRealPath(dir.value().c_str());
CHECK_FAIL_RETURN_UNEXPECTED(
realpath.has_value(), "Invalid file, failed to get the realpath of mindrecord files. Please check file: " + file);
@ -518,7 +518,7 @@ Status ShardWriter::LockWriter(bool parallel_writer, std::unique_ptr<int> *fd_pt
// Open files
file_streams_.clear();
for (const auto &file : file_paths_) {
auto realpath = FileUtils::GetRealPath(file.data());
auto realpath = FileUtils::GetRealPath(file.c_str());
if (!realpath.has_value()) {
close(fd);
RETURN_STATUS_UNEXPECTED("[Internal ERROR] Failed to get real path, path: " + file);

View File

@ -60,7 +60,7 @@ Status ShardHeader::InitializeHeader(const std::vector<json> &headers, bool load
}
Status ShardHeader::CheckFileStatus(const std::string &path) {
auto realpath = FileUtils::GetRealPath(path.data());
auto realpath = FileUtils::GetRealPath(path.c_str());
CHECK_FAIL_RETURN_UNEXPECTED(
realpath.has_value(),
"Invalid file, failed to get the realpath of mindrecord files. Please check file path: " + path);
@ -92,7 +92,7 @@ Status ShardHeader::ValidateHeader(const std::string &path, std::shared_ptr<json
RETURN_UNEXPECTED_IF_NULL(header_ptr);
RETURN_IF_NOT_OK(CheckFileStatus(path));
auto realpath = FileUtils::GetRealPath(path.data());
auto realpath = FileUtils::GetRealPath(path.c_str());
CHECK_FAIL_RETURN_UNEXPECTED(
realpath.has_value(),
"Invalid file, failed to get the realpath of mindrecord files. Please check file path: " + path);
@ -630,7 +630,7 @@ Status ShardHeader::GetStatisticByID(int64_t statistic_id, std::shared_ptr<Stati
}
Status ShardHeader::PagesToFile(const std::string dump_file_name) {
auto realpath = FileUtils::GetRealPath(dump_file_name.data());
auto realpath = FileUtils::GetRealPath(dump_file_name.c_str());
CHECK_FAIL_RETURN_UNEXPECTED(realpath.has_value(),
"[Internal ERROR] Failed to get the realpath of Pages file, path: " + dump_file_name);
// write header content to file, dump whatever is in the file before
@ -649,7 +649,7 @@ Status ShardHeader::FileToPages(const std::string dump_file_name) {
for (auto &v : pages_) { // clean pages
v.clear();
}
auto realpath = FileUtils::GetRealPath(dump_file_name.data());
auto realpath = FileUtils::GetRealPath(dump_file_name.c_str());
CHECK_FAIL_RETURN_UNEXPECTED(realpath.has_value(),
"[Internal ERROR] Failed to get the realpath of Pages file, path: " + dump_file_name);
// attempt to open the file contains the page in json