15#ifndef IMGUI_FILESYSTEM_H_
16#define IMGUI_FILESYSTEM_H_
70#ifndef IMGUIFS_NO_EXTRA_METHODS
74# if (defined(__linux__) && !defined(PATH_MAX))
75# include <linux/limits.h>
81# define FILENAME_MAX PATH_MAX
86# if (defined(MAX_PATH) && MAX_PATH>PATH_MAX)
87# define DIRENT_MAX_PATH MAX_PATH
89# define DIRENT_MAX_PATH PATH_MAX
95#ifndef IMGUIFS_NO_EXTRA_METHODS
96# if (!defined(IMGUIFS_MEMORY_USES_CHARS_AS_BYTES) || !defined(IMGUIFILESYSTEM_USE_ASCII_SHORT_PATHS_ON_WINDOWS))
106# ifdef IMGUI_USE_MINIZIP
107# error Please undefine IMGUIFS_NO_EXTRA_METHODS for IMGUI_USE_MINIZIP to work
135 IMGUI_API
Dialog(
bool noKnownDirectoriesSection=
false,
bool noCreateDirectorySection=
false,
bool noFilteringSection=
false,
bool detectKnownDirectoriesAtEachOpening=
false,
bool addDisplayByOption=
false,
bool dontFilterSaveFilePathsEnteredByTheUser=
false);
142 IMGUI_API
const char*
chooseFileDialog(
bool dialogTriggerButton,
const char* directory=NULL,
const char* fileFilterExtensionString=NULL,
const char* windowTitle=NULL,
const ImVec2& windowSize=ImVec2(-1,-1),
const ImVec2& windowPos=ImVec2(-1,-1),
const float windowAlpha=0.875f);
143 IMGUI_API
const char*
chooseFolderDialog(
bool dialogTriggerButton,
const char* directory=NULL,
const char* windowTitle=NULL,
const ImVec2& windowSize=ImVec2(-1,-1),
const ImVec2& windowPos=ImVec2(-1,-1),
const float windowAlpha=0.875f);
144 IMGUI_API
const char*
saveFileDialog(
bool dialogTriggerButton,
const char* directory=NULL,
const char* startingFileNameEntry=NULL,
const char* fileFilterExtensionString=NULL,
const char* windowTitle=NULL,
const ImVec2& windowSize=ImVec2(-1,-1),
const ImVec2& windowPos=ImVec2(-1,-1),
const float windowAlpha=0.875f);
167 friend const char*
ChooseFileMainMethod(
Dialog& ist,
const char* directory,
const bool _isFolderChooserDialog,
const bool _isSaveFileDialog,
const char* _saveFileName,
const char* fileFilterExtensionString,
const char* windowTitle,
const ImVec2& windowSize,
const ImVec2& windowPos,
const float windowAlpha);
171#ifndef IMGUIFS_NO_EXTRA_METHODS
187extern void PathAppend(
const char* directory,
char* rv);
206extern bool FileGetContent(
const char* path,ImVector<unsigned char>& bufferOut,
bool openInTextMode=
false,
const char* password=NULL);
207extern bool FileGetContent(
const char* path,ImVector<char>& bufferOut,
bool openInTextMode=
false,
const char* password=NULL);
210#if (defined(__EMSCRIPTEN__) && defined(EMSCRIPTEN_SAVE_SHELL))
211extern bool FileDownload(
const char* path,
const char* optionalSaveFileName);
213#ifdef IMGUI_USE_MINIZIP
216UnZipFile(
const char* zipFilePath=NULL);
217bool load(
const char* zipFilePath,
bool reloadIfAlreadyLoaded=
true);
218const char* getZipFilePath()
const;
223bool getDirectories(
const char* directoryName,PathStringVector& result,FilenameStringVector* pOptionalNamesOut=NULL,Sorting sorting= SORT_ORDER_ALPHABETIC,
bool prefixResultWithTheFullPathOfTheZipFile=
false)
const;
224bool getFiles(
const char* directoryName,PathStringVector& result,FilenameStringVector* pOptionalNamesOut=NULL,Sorting sorting= SORT_ORDER_ALPHABETIC,
bool prefixResultWithTheFullPathOfTheZipFile=
false)
const;
225unsigned int getFileSize(
const char* filePath)
const;
226bool getFileContent(
const char* filePath,ImVector<unsigned char>& bufferOut,
const char* password=NULL)
const;
227bool getFileContent(
const char* filePath,ImVector<char>& bufferOut,
const char* password=NULL)
const;
228bool exists(
const char* pathInsideZip,
bool reportOnlyFiles=
false,
bool reportOnlyDirectories=
false)
const;
229bool fileExists(
const char* pathInsideZip)
const;
230bool directoryExists(
const char* pathInsideZip)
const;
233struct UnZipFileImpl* im;
237extern bool PathSplitFirstZipFolder(
const char* path,
char* rv1,
char* rv2,
bool rv1IsAbsolutePath=
true);
239extern bool PathExistsWithZipSupport(
const char* path,
bool reportOnlyFiles=
false,
bool reportOnlyDirectories=
false,
bool checkAbsolutePath=
true,
bool *isInsideAZipFile=NULL);
241extern bool PathIsInsideAZipFile(
const char* path);
245extern void PathGetDirectoryNameWithZipSupport(
const char* path,
char* rv,
bool prefixResultWithTheFullPathOfTheZipFile=
true);
246extern void PathGetAbsoluteWithZipSupport(
const char* path,
char* rv);
const int MAX_FILENAME_BYTES
void PathGetAbsolute(const char *path, char *rv)
void PathGetFileNameWithoutExtension(const char *filePath, char *rv)
ImVector< FilenameString > FilenameStringVector
void FileGetExtensionTypesFromFilenames(ImVector< int > &fileExtensionTypesOut, const FilenameStringVector &fileNames)
char PathString[MAX_PATH_BYTES]
void PathGetFileName(const char *filePath, char *rv)
void PathChangeExtension(const char *filePath, const char *newExtension, char *rv)
int FileGetExtensionType(const char *path)
@ SORT_ORDER_TYPE_INVERSE
@ SORT_ORDER_LAST_MODIFICATION
@ SORT_ORDER_ALPHABETIC_INVERSE
@ SORT_ORDER_LAST_MODIFICATION_INVERSE
@ SORT_ORDER_SIZE_INVERSE
void DirectoryCreate(const char *directoryName)
void PathGetExtension(const char *filePath, char *rv)
bool PathExists(const char *path)
void DirectoryGetDirectories(const char *directoryName, PathStringVector &result, FilenameStringVector *pOptionalNamesOut, Sorting sorting)
void DirectoryGetFiles(const char *directoryName, PathStringVector &result, FilenameStringVector *pOptionalNamesOut, Sorting sorting)
ImVector< PathString > PathStringVector
bool FileGetContent(const char *path, ImVector< unsigned char > &bufferOut, bool openInTextMode, const char *password)
bool DirectoryExists(const char *path)
void PathGetDirectoryName(const char *filePath, char *rv)
void PathAppend(const char *directory, char *rv)
void PathSplit(const char *path, FilenameStringVector &rv, bool leaveIntermediateTrailingSlashes)
char FilenameString[MAX_FILENAME_BYTES]
bool FileExists(const char *path)
IMGUI_API const char * getLastDirectory() const
IMGUI_API const char * chooseFileDialog(bool dialogTriggerButton, const char *directory=NULL, const char *fileFilterExtensionString=NULL, const char *windowTitle=NULL, const ImVec2 &windowSize=ImVec2(-1,-1), const ImVec2 &windowPos=ImVec2(-1,-1), const float windowAlpha=0.875f)
static DrawFileIconDelegate DrawFileIconCallback
bool(* DrawFolderIconDelegate)(bool useOpenFolderIconIfAvailable, const ImVec4 *pOptionalColorOverride)
IMGUI_API bool hasUserJustCancelledDialog() const
static ImGuiWindowFlags ExtraWindowFlags
IMGUI_API const char * getChosenPath() const
static DrawFolderIconDelegate DrawFolderIconCallback
static ImVec4 WindowLTRBOffsets
IMGUI_API const char * chooseFolderDialog(bool dialogTriggerButton, const char *directory=NULL, const char *windowTitle=NULL, const ImVec2 &windowSize=ImVec2(-1,-1), const ImVec2 &windowPos=ImVec2(-1,-1), const float windowAlpha=0.875f)
bool(* DrawFileIconDelegate)(int fileExtensionType, const ImVec4 *pOptionalColorOverride)
IMGUI_API const char * saveFileDialog(bool dialogTriggerButton, const char *directory=NULL, const char *startingFileNameEntry=NULL, const char *fileFilterExtensionString=NULL, const char *windowTitle=NULL, const ImVec2 &windowSize=ImVec2(-1,-1), const ImVec2 &windowPos=ImVec2(-1,-1), const float windowAlpha=0.875f)
struct Internal * internal
friend const char * ChooseFileMainMethod(Dialog &ist, const char *directory, const bool _isFolderChooserDialog, const bool _isSaveFileDialog, const char *_saveFileName, const char *fileFilterExtensionString, const char *windowTitle, const ImVec2 &windowSize, const ImVec2 &windowPos, const float windowAlpha)