Modify directoryExists function of FsAccess class

Signed-off-by: Mayank Raghuwanshi <mayank.raghuwanshi@intel.com>
This commit is contained in:
Mayank Raghuwanshi
2021-07-08 18:05:38 +05:30
committed by Compute-Runtime-Automation
parent 8810547d3a
commit f592a82fea
4 changed files with 38 additions and 16 deletions

View File

@@ -278,12 +278,10 @@ bool FsAccess::isRootUser() {
}
bool FsAccess::directoryExists(const std::string path) {
::DIR *pDir = ::opendir(path.c_str());
if (pDir != NULL) {
::closedir(pDir);
return true;
if (accessSyscall(path.c_str(), F_OK)) {
return false;
}
return false;
return true;
}
// Procfs Access
@@ -564,7 +562,7 @@ bool SysfsAccess::fileExists(const std::string file) {
}
bool SysfsAccess::directoryExists(const std::string path) {
return FsAccess::fileExists(fullPath(path).c_str());
return FsAccess::directoryExists(fullPath(path).c_str());
}
bool SysfsAccess::isMyDeviceFile(const std::string dev) {

View File

@@ -7,6 +7,8 @@
#pragma once
#include "shared/source/os_interface/linux/sys_calls.h"
#include "level_zero/ze_api.h"
#include "level_zero/zet_api.h"
@@ -52,6 +54,7 @@ class FsAccess {
protected:
FsAccess();
decltype(&NEO::SysCalls::access) accessSyscall = NEO::SysCalls::access;
};
class ProcfsAccess : private FsAccess {
@@ -77,7 +80,7 @@ class ProcfsAccess : private FsAccess {
static const std::string fdDir;
};
class SysfsAccess : private FsAccess {
class SysfsAccess : protected FsAccess {
public:
static SysfsAccess *create(const std::string file);
SysfsAccess() = default;