mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-12-14 20:19:38 +00:00
Restrict file browser UI by file type
This commit is contained in:
@@ -6,12 +6,14 @@
|
||||
#include "FontFamily.h"
|
||||
#include "GpApplicationName.h"
|
||||
#include "GpBuildVersion.h"
|
||||
#include "GpIOStream.h"
|
||||
#include "GpRenderedFontMetrics.h"
|
||||
#include "HostFileSystem.h"
|
||||
#include "HostDirectoryCursor.h"
|
||||
#include "HostSystemServices.h"
|
||||
#include "IGpFont.h"
|
||||
#include "WindowManager.h"
|
||||
#include "MacFileInfo.h"
|
||||
#include "MemoryManager.h"
|
||||
#include "PLStandardColors.h"
|
||||
#include "RenderedFont.h"
|
||||
@@ -175,11 +177,11 @@ namespace PortabilityLayer
|
||||
size_t oldSize = m_entries.MMBlock()->m_size;
|
||||
|
||||
if (!mm->ResizeHandle(m_entries.MMBlock(), oldSize + sizeof(FileEntry)))
|
||||
return false;
|
||||
return false;
|
||||
|
||||
FileEntry &entry = (*m_entries)[m_numEntries++];
|
||||
entry.m_nameStr = NameStr_t(nameLen, name);
|
||||
entry.m_fileDetails = details;
|
||||
entry.m_fileDetails = details;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -562,7 +564,7 @@ namespace PortabilityLayer
|
||||
return hit;
|
||||
}
|
||||
|
||||
bool FileBrowserUI::Prompt(Mode mode, VirtualDirectory_t dirID, char *path, size_t &outPathLength, size_t pathCapacity, const PLPasStr &initialFileName, const PLPasStr &promptText, const FileBrowserUI_DetailsCallbackAPI &callbackAPI)
|
||||
bool FileBrowserUI::Prompt(Mode mode, VirtualDirectory_t dirID, const ResTypeID &fileType, char *path, size_t &outPathLength, size_t pathCapacity, const PLPasStr &initialFileName, const PLPasStr &promptText, const FileBrowserUI_DetailsCallbackAPI &callbackAPI)
|
||||
{
|
||||
int dialogID = 0;
|
||||
bool isObstructive = false;
|
||||
@@ -607,6 +609,27 @@ namespace PortabilityLayer
|
||||
|
||||
if (!memcmp(nameExt, ".gpf", 4))
|
||||
{
|
||||
GpIOStream *metadataStream = fs->OpenFile(dirID, fileName, false, GpFileCreationDispositions::kOpenExisting);
|
||||
if (!metadataStream)
|
||||
continue;
|
||||
|
||||
MacFilePropertiesSerialized serializedMetadata;
|
||||
if (metadataStream->Read(&serializedMetadata, sizeof(serializedMetadata)) != sizeof(serializedMetadata))
|
||||
{
|
||||
metadataStream->Close();
|
||||
continue;
|
||||
}
|
||||
|
||||
metadataStream->Close();
|
||||
|
||||
MacFileProperties metadata;
|
||||
serializedMetadata.Deserialize(metadata);
|
||||
|
||||
char ftype[4];
|
||||
fileType.ExportAsChars(ftype);
|
||||
if (memcmp(metadata.m_fileType, ftype, 4))
|
||||
continue;
|
||||
|
||||
if (!uiImpl.AppendName(fileName, nameLength - 4, callbackAPI.m_loadFileDetailsCallback(dirID, PLPasStr(nameLength - 4, fileName))))
|
||||
{
|
||||
dirCursor->Destroy();
|
||||
@@ -779,7 +802,7 @@ namespace PortabilityLayer
|
||||
outPathLength = uiFileName.Length();
|
||||
}
|
||||
|
||||
dialog->Destroy();
|
||||
dialog->Destroy();
|
||||
|
||||
return confirmed;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user