wdc-utils/set_file_type.cpp

21 lines
385 B
C++
Raw Normal View History

2017-01-11 19:05:12 +00:00
#include <string>
#include <stdint.h>
2017-08-09 00:16:58 +00:00
#include <system_error>
#include <afp/finder_info.h>
2017-01-11 19:05:12 +00:00
2017-01-11 19:28:18 +00:00
int set_file_type(const std::string &path, uint16_t file_type, uint32_t aux_type) {
2017-01-11 19:05:12 +00:00
2017-08-09 00:16:58 +00:00
afp::finder_info fi;
2017-03-06 05:39:50 +00:00
std::error_code ec;
2017-08-09 00:16:58 +00:00
if (!fi.open(path, afp::finder_info::read_write, ec))
return -1;
2017-01-23 15:02:50 +00:00
fi.set_prodos_file_type(file_type, aux_type);
2017-08-09 00:16:58 +00:00
if (!fi.write(ec))
return -1;
2017-01-11 19:05:12 +00:00
2017-08-09 00:16:58 +00:00
return 0;
2017-01-11 19:05:12 +00:00
}