mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 01:04:57 +08:00
Add FsAccess::getFileMode and SysfsAccess::getFileMode methods
Change-Id: I4dddf1b3983e63ef6ad664009ebd20d474c8cc17 Signed-off-by: Bill Jordan <bill.jordan@intel.com>
This commit is contained in:
@@ -119,6 +119,15 @@ ze_result_t FsAccess::canWrite(const std::string file) {
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t FsAccess::getFileMode(const std::string file, ::mode_t &mode) {
|
||||
struct stat sb;
|
||||
if (0 != stat(file.c_str(), &sb)) {
|
||||
return getResult(errno);
|
||||
}
|
||||
mode = sb.st_mode;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t FsAccess::readSymLink(const std::string path, std::string &val) {
|
||||
// returns the value of symlink at path
|
||||
char buf[PATH_MAX];
|
||||
@@ -305,6 +314,11 @@ ze_result_t SysfsAccess::canWrite(const std::string file) {
|
||||
return FsAccess::canWrite(fullPath(file));
|
||||
}
|
||||
|
||||
ze_result_t SysfsAccess::getFileMode(const std::string file, ::mode_t &mode) {
|
||||
// Prepend sysfs directory path and call the base getFileMode
|
||||
return FsAccess::getFileMode(fullPath(file), mode);
|
||||
}
|
||||
|
||||
ze_result_t SysfsAccess::read(const std::string file, std::string &val) {
|
||||
// Prepend sysfs directory path and call the base read
|
||||
return FsAccess::read(fullPath(file).c_str(), val);
|
||||
|
||||
@@ -30,6 +30,7 @@ class FsAccess {
|
||||
|
||||
ze_result_t canRead(const std::string file);
|
||||
ze_result_t canWrite(const std::string file);
|
||||
ze_result_t getFileMode(const std::string file, ::mode_t &mode);
|
||||
|
||||
ze_result_t read(const std::string file, std::string &val);
|
||||
ze_result_t read(const std::string file, std::vector<std::string> &val);
|
||||
@@ -74,6 +75,7 @@ class SysfsAccess : private FsAccess {
|
||||
|
||||
ze_result_t canRead(const std::string file);
|
||||
ze_result_t canWrite(const std::string file);
|
||||
ze_result_t getFileMode(const std::string file, ::mode_t &mode);
|
||||
|
||||
ze_result_t read(const std::string file, std::string &val);
|
||||
ze_result_t read(const std::string file, int &val);
|
||||
|
||||
Reference in New Issue
Block a user