ApraLinuxUtils 1.0.0
C++ utility library for embedded Linux systems
 
Loading...
Searching...
No Matches
FileIO.cpp
Go to the documentation of this file.
1/*
2 * FileIO.cpp
3 *
4 * Copyright (c) 2024 Apra Labs
5 *
6 * This file is part of ApraUtils.
7 *
8 * Licensed under the MIT License.
9 * See LICENSE file in the project root for full license information.
10 */
11
12#include "utils/FileIO.h"
13#include <sys/stat.h>
14
15using namespace apra;
16
17FileIO::FileIO()
18{
19
20}
21
22FileIO::~FileIO()
23{
24}
25
26bool FileIO::isFileExist(const string &path)
27{
28 bool returnValue;
29 struct stat info;
30 if (stat(path.c_str(), &info) != 0)
31 {
32 returnValue = false;
33 }
34 else
35 {
36 returnValue = S_ISREG(info.st_mode) != 0;
37 }
38 return returnValue;
39}
40
41bool FileIO::isDirectoryExist(const string &path)
42{
43 bool returnValue;
44 struct stat info;
45 if (stat(path.c_str(), &info) != 0)
46 {
47 returnValue = false;
48 }
49 else
50 {
51 returnValue = S_ISDIR(info.st_mode) != 0;
52 }
53 return returnValue;
54}
55
static bool isFileExist(const string &path)
Definition FileIO.cpp:26
static bool isDirectoryExist(const string &path)
Definition FileIO.cpp:41