43 std::unique_ptr<char[]> buffer = std::make_unique<char[]>(
static_cast<size_t>(size + 1));
44 std::string ret_value;
46 if (buffer !=
nullptr)
48 std::memcpy(buffer.get(), txt,
static_cast<size_t>(size));
49 *(buffer.get() + size) =
'\0';
51 ret_value = buffer.get();
56 return trim(ret_value);
64bool locate_file(
const std::string & path,
const std::string & filename, std::string & fullname,
bool & is_vcd)
69 fullname = path +
"VCD/" + filename +
".VCD";
71 if (!access(fullname.c_str(), F_OK))
77 fullname = path +
"SVCD/" + filename +
".SVD";
79 if (!access(fullname.c_str(), F_OK))
88int locate_video(
const std::string & path,
int track_no, std::string & fullname)
93 strsprintf(&buffer,
"MPEGAV/AVSEQ%02i.DAT", track_no - 1);
94 fullname = path + buffer;
95 if (!access(fullname.c_str(), F_OK))
101 strsprintf(&buffer,
"MPEG2/AVSEQ%02i.MPG", track_no - 1);
102 fullname = path + buffer;
103 if (!access(fullname.c_str(), F_OK))
117 return "VCD 1.0, VCD 1.1, SVCD 1.0, HQVCD";
138 return "VCD 1.0, VCD 2.0, SVCD, HQVCD";
155 stat(fullname.c_str(), &stbuf);
157 if (S_ISDIR(stbuf.st_mode))
160 *directory = fullname;
167 *directory = fullname;
std::string & trim(std::string &s)
trim from both ends
const std::string & remove_filename(std::string *filepath)
Remove filename from path. Handy dirname alternative.
const std::string & append_sep(std::string *path)
Add / to the path if required.
Various FFmpegfs utility functions.
const std::string & strsprintf(std::string *str, const std::string &format, Args ... args)
Format a std::string sprintf-like.
Main include for FFmpegfs project.
Video CD utility functions.
bool locate_file(const std::string &path, const std::string &filename, std::string &fullname, bool &is_vcd)
Check if path is a S/VCD.
int locate_video(const std::string &path, int track_no, std::string &fullname)
Locate AVSEQ*DAT/MPEG video file for track_no.
std::string convert_txt2string(const char *txt, int size, bool trimmed)
Non-zero terminated text is converted to std::string.
void get_directory(const std::string &fullname, std::string *directory)
Check if fullname is a directory. Remove the filename if necessary.
std::string get_type_str(VCDTYPE type)
Return disk type as a human readable string.
std::string get_profile_tag_str(VCDPROFILETAG tag)
Profile as a human readable string.
@ VCD_10_11_SVCD_10_HQVCD
VCD 1.0, VCD 1.1, SVCD 1.0 und HQVCD.
@ VCD_10_20_SVCD_HQVCD
VCD 1.0, VCD 2.0, SVCD und HQVCD.