1//========================================================================
2//
3// gfile.h
4//
5// Miscellaneous file and directory name manipulation.
6//
7// Copyright 1996-2003 Glyph & Cog, LLC
8//
9//========================================================================
10
11//========================================================================
12//
13// Modified under the Poppler project - http://poppler.freedesktop.org
14//
15// All changes made under the Poppler project to this file are licensed
16// under GPL version 2 or later
17//
18// Copyright (C) 2006 Kristian Høgsberg <krh@redhat.com>
19// Copyright (C) 2009, 2011, 2012, 2017, 2018, 2021, 2022 Albert Astals Cid <aacid@kde.org>
20// Copyright (C) 2009 Kovid Goyal <kovid@kovidgoyal.net>
21// Copyright (C) 2013 Adam Reichold <adamreichold@myopera.com>
22// Copyright (C) 2013, 2017 Adrian Johnson <ajohnson@redneon.com>
23// Copyright (C) 2014 Bogdan Cristea <cristeab@gmail.com>
24// Copyright (C) 2014 Peter Breitenlohner <peb@mppmu.mpg.de>
25// Copyright (C) 2017 Christoph Cullmann <cullmann@kde.org>
26// Copyright (C) 2017 Thomas Freitag <Thomas.Freitag@alfa.de>
27// Copyright (C) 2018 Mojca Miklavec <mojca@macports.org>
28// Copyright (C) 2019 Christian Persch <chpe@src.gnome.org>
29//
30// To see a description of the changes please see the Changelog file that
31// came with your tarball or type make ChangeLog if you are building from git
32//
33//========================================================================
34
35#ifndef GDIR_H
36#define GDIR_H
37
38#include "poppler-config.h"
39
40#include <memory>
41
42class GooString;
43
44#if defined(_WIN32)
45# include <windows.h>
46#else
47# include <dirent.h>
48#endif
49
50//------------------------------------------------------------------------
51// GDir and GDirEntry
52//------------------------------------------------------------------------
53
54class GDirEntry
55{
56public:
57 GDirEntry(const char *dirPath, const char *nameA, bool doStat);
58 ~GDirEntry();
59
60 GDirEntry(const GDirEntry &other) = delete;
61 GDirEntry &operator=(const GDirEntry &other) = delete;
62
63 const GooString *getName() const { return name; }
64 const GooString *getFullPath() const { return fullPath; }
65 bool isDir() const { return dir; }
66
67private:
68 GooString *name; // dir/file name
69 GooString *fullPath;
70 bool dir; // is it a directory?
71};
72
73class GDir
74{
75public:
76 explicit GDir(const char *name, bool doStatA = true);
77 ~GDir();
78
79 GDir(const GDir &other) = delete;
80 GDir &operator=(const GDir &other) = delete;
81
82 std::unique_ptr<GDirEntry> getNextEntry();
83 void rewind();
84
85private:
86 GooString *path; // directory path
87 bool doStat; // call stat() for each entry?
88#if defined(_WIN32)
89 WIN32_FIND_DATAA ffd;
90 HANDLE hnd;
91#else
92 DIR *dir; // the DIR structure from opendir()
93#endif
94};
95
96#endif
97

source code of poppler/goo/gdir.h