Answer the question
In order to leave comments, you need to log in
What's wrong with the maximum filename length limit?
In general, I found that under Windows the limit is 255 characters, and under Linux it is 255 bytes, and I wrote this code to copy files with renaming (there, the coordinates of rectangles are stored in the name, and there can be a lot of them, not the best solution, but this is not I figured it out).
std::string filename = current_image->path().stem().string();
#if OS == LINUX
for (const auto& ch : filename)
if (!std::isalpha(ch) && !std::isdigit(ch) &&
ch != ' ' && ch != '.' &&ch != '-' && ch != '_')
{
QMessageBox::warning(
this, "Warning",
"Файл не будет сохранён, т.к. содержит недопустимые символы в "
"своём имени.\nДопустимые символы: латинские буквы, цифры, "
"пробел, точка, '-' и '_'."
);
goto filename_invalidity;
}
#endif
for (const auto& rect : rect_grabber->getRects())
{
std::string rect_data = "_["
+ std::to_string(rect.x()) + "," + std::to_string(rect.y()) + ","
+ std::to_string(rect.width()) + "," + std::to_string(rect.height()) + ","
+ rect.getType() + "]";
if (filename.size() + rect_data.size()
+ current_image->path().extension().string().size() <= 255)
{
filename += rect_data;
}
else
{
QMessageBox::warning(
this, "Warning",
"Имя файла превысило максимально допустимую длину (255 символов)."
" Часть данных разметки не будет сохранена в имени файла."
);
break;
}
}
filename += current_image->path().extension().string();
fs::copy(current_image->path(),fs::path{load_window->getOutDirPath()/filename});
}
Answer the question
In order to leave comments, you need to log in
Under Windows, the limit is 32 kilobytes. Look for the corresponding functions, by the way, this is also in Linux. Plus there is a damn joke to create a folder, go into it and create a folder. In general, all descriptors on the file system are selected, and you can delete it only by going down and deleting folders by going up
In general, I found that under Windows the limit is 255 characters
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question