Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-11 10:26:09

0001 //========================================================================
0002 //
0003 // gfile.h
0004 //
0005 // Miscellaneous file and directory name manipulation.
0006 //
0007 // Copyright 1996-2003 Glyph & Cog, LLC
0008 //
0009 //========================================================================
0010 
0011 //========================================================================
0012 //
0013 // Modified under the Poppler project - http://poppler.freedesktop.org
0014 //
0015 // All changes made under the Poppler project to this file are licensed
0016 // under GPL version 2 or later
0017 //
0018 // Copyright (C) 2006 Kristian Høgsberg <krh@redhat.com>
0019 // Copyright (C) 2009, 2011, 2012, 2017, 2018, 2021, 2022 Albert Astals Cid <aacid@kde.org>
0020 // Copyright (C) 2009 Kovid Goyal <kovid@kovidgoyal.net>
0021 // Copyright (C) 2013 Adam Reichold <adamreichold@myopera.com>
0022 // Copyright (C) 2013, 2017 Adrian Johnson <ajohnson@redneon.com>
0023 // Copyright (C) 2014 Bogdan Cristea <cristeab@gmail.com>
0024 // Copyright (C) 2014 Peter Breitenlohner <peb@mppmu.mpg.de>
0025 // Copyright (C) 2017 Christoph Cullmann <cullmann@kde.org>
0026 // Copyright (C) 2017 Thomas Freitag <Thomas.Freitag@alfa.de>
0027 // Copyright (C) 2018 Mojca Miklavec <mojca@macports.org>
0028 // Copyright (C) 2019 Christian Persch <chpe@src.gnome.org>
0029 //
0030 // To see a description of the changes please see the Changelog file that
0031 // came with your tarball or type make ChangeLog if you are building from git
0032 //
0033 //========================================================================
0034 
0035 #ifndef GDIR_H
0036 #define GDIR_H
0037 
0038 #include "poppler-config.h"
0039 
0040 #include <memory>
0041 
0042 class GooString;
0043 
0044 #if defined(_WIN32)
0045 #    include <windows.h>
0046 #else
0047 #    include <dirent.h>
0048 #endif
0049 
0050 //------------------------------------------------------------------------
0051 // GDir and GDirEntry
0052 //------------------------------------------------------------------------
0053 
0054 class GDirEntry
0055 {
0056 public:
0057     GDirEntry(const char *dirPath, const char *nameA, bool doStat);
0058     ~GDirEntry();
0059 
0060     GDirEntry(const GDirEntry &other) = delete;
0061     GDirEntry &operator=(const GDirEntry &other) = delete;
0062 
0063     const GooString *getName() const { return name; }
0064     const GooString *getFullPath() const { return fullPath; }
0065     bool isDir() const { return dir; }
0066 
0067 private:
0068     GooString *name; // dir/file name
0069     GooString *fullPath;
0070     bool dir; // is it a directory?
0071 };
0072 
0073 class GDir
0074 {
0075 public:
0076     explicit GDir(const char *name, bool doStatA = true);
0077     ~GDir();
0078 
0079     GDir(const GDir &other) = delete;
0080     GDir &operator=(const GDir &other) = delete;
0081 
0082     std::unique_ptr<GDirEntry> getNextEntry();
0083     void rewind();
0084 
0085 private:
0086     GooString *path; // directory path
0087     bool doStat; // call stat() for each entry?
0088 #if defined(_WIN32)
0089     WIN32_FIND_DATAA ffd;
0090     HANDLE hnd;
0091 #else
0092     DIR *dir; // the DIR structure from opendir()
0093 #endif
0094 };
0095 
0096 #endif