Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
fx_folder_posix.cpp
Go to the documentation of this file.
1
// Copyright 2021 The PDFium Authors
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7
#
include
"core/fxcrt/fx_folder.h"
8
9
#
include
<
memory
>
10
11
#
include
"build/build_config.h"
12
#
include
"core/fxcrt/ptr_util.h"
13
#
include
"core/fxcrt/unowned_ptr.h"
14
15
#
if
BUILDFLAG
(
IS_WIN
)
16
#
error
"built on wrong platform"
17
#
endif
18
19
#
include
<
dirent
.
h
>
20
#
include
<
sys
/
stat
.
h
>
21
#
include
<
unistd
.
h
>
22
23
class
FX_PosixFolder
:
public
FX_Folder
{
24
public
:
25
~
FX_PosixFolder
()
override
;
26
27
bool
GetNextFile
(
ByteString
* filename,
bool
* bFolder)
override
;
28
29
private
:
30
friend
class
FX_Folder
;
31
FX_PosixFolder(
const
ByteString
& path, DIR* dir);
32
33
const
ByteString
m_Path;
34
UnownedPtr
<DIR> m_Dir;
35
};
36
37
std::unique_ptr<FX_Folder>
FX_Folder
::OpenFolder(
const
ByteString
& path) {
38
DIR* dir = opendir(path.c_str());
39
if
(!dir)
40
return
nullptr
;
41
42
// Private ctor.
43
return
pdfium
::WrapUnique(
new
FX_PosixFolder
(path, dir));
44
}
45
46
FX_PosixFolder
::FX_PosixFolder(
const
ByteString
& path, DIR* dir)
47
: m_Path(path), m_Dir(dir) {}
48
49
FX_PosixFolder
::~
FX_PosixFolder
() {
50
closedir(m_Dir.ExtractAsDangling());
51
}
52
53
bool
FX_PosixFolder
::
GetNextFile
(
ByteString
* filename,
bool
* bFolder) {
54
struct
dirent* de = readdir(m_Dir);
55
if
(!de)
56
return
false
;
57
58
ByteString
fullpath = m_Path +
"/"
+ de->d_name;
59
struct
stat deStat;
60
if
(stat(fullpath.c_str(), &deStat) < 0)
61
return
false
;
62
63
*filename
=
de->d_name;
64
*bFolder = S_ISDIR(deStat.st_mode);
65
return
true
;
66
}
ByteString
fxcrt::ByteString ByteString
Definition
bytestring.h:180
FX_Folder
Definition
fx_folder.h:14
FX_PosixFolder
Definition
fx_folder_posix.cpp:23
FX_PosixFolder::GetNextFile
bool GetNextFile(ByteString *filename, bool *bFolder) override
Definition
fx_folder_posix.cpp:53
FX_PosixFolder::~FX_PosixFolder
~FX_PosixFolder() override
Definition
fx_folder_posix.cpp:49
fxcrt::ByteString::operator=
ByteString & operator=(const char *str)
Definition
bytestring.cpp:150
fxcrt::UnownedPtr
Definition
unowned_ptr.h:76
pdfium::CFDETextOutLargeBitmapTest
Definition
cfde_textout_unittest.cpp:117
qtwebengine
src
3rdparty
chromium
third_party
pdfium
core
fxcrt
fx_folder_posix.cpp
Generated on
for Qt by
1.18.0