aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Rusak <lorusak@gmail.com>2020-02-10 16:00:17 +0000
committerGitHub <noreply@github.com>2020-02-10 16:00:17 +0000
commit4123ff42f7e75daf24d5ffe5802c826766bb339d (patch)
tree5668077f7e1e785c6eb607062a4c81a8404061c7
parentb1547ab3c8b192ae8da91d3e13fae9f7af60e680 (diff)
parent48e6c7666358f31c0b78a33494e688cf04d0c49a (diff)
Merge pull request #17335 from lrusak/systemtime-defines-part2
PlatformDefs.h: move WIN32_FIND_DATA to iso9660.h
-rw-r--r--xbmc/filesystem/ISO9660Directory.cpp24
-rw-r--r--xbmc/filesystem/iso9660.cpp67
-rw-r--r--xbmc/filesystem/iso9660.h18
-rw-r--r--xbmc/platform/posix/PlatformDefs.h14
4 files changed, 53 insertions, 70 deletions
diff --git a/xbmc/filesystem/ISO9660Directory.cpp b/xbmc/filesystem/ISO9660Directory.cpp
index 3aba79d641..276ab650e6 100644
--- a/xbmc/filesystem/ISO9660Directory.cpp
+++ b/xbmc/filesystem/ISO9660Directory.cpp
@@ -35,7 +35,7 @@ bool CISO9660Directory::GetDirectory(const CURL& url, CFileItemList &items)
if (!m_isoReader.IsScanned())
m_isoReader.Scan();
- WIN32_FIND_DATA wfd;
+ Win32FindData wfd;
HANDLE hFind;
memset(&wfd, 0, sizeof(wfd));
@@ -61,15 +61,11 @@ bool CISO9660Directory::GetDirectory(const CURL& url, CFileItemList &items)
do
{
- if (wfd.cFileName[0] != 0)
+ if (wfd.fileName[0] != 0)
{
- if ( (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
+ if ((wfd.fileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
-#ifdef TARGET_WINDOWS
- auto strDir = KODI::PLATFORM::WINDOWS::FromW(wfd.cFileName);
-#else
- std::string strDir = wfd.cFileName;
-#endif
+ std::string strDir = wfd.fileName;
if (strDir != "." && strDir != "..")
{
CFileItemPtr pItem(new CFileItem(strDir));
@@ -78,24 +74,20 @@ bool CISO9660Directory::GetDirectory(const CURL& url, CFileItemList &items)
pItem->SetPath(path);
pItem->m_bIsFolder = true;
FILETIME localTime;
- KODI::TIME::FileTimeToLocalFileTime(&wfd.ftLastWriteTime, &localTime);
+ KODI::TIME::FileTimeToLocalFileTime(&wfd.lastWriteTime, &localTime);
pItem->m_dateTime=localTime;
items.Add(pItem);
}
}
else
{
-#ifdef TARGET_WINDOWS
- auto strDir = KODI::PLATFORM::WINDOWS::FromW(wfd.cFileName);
-#else
- std::string strDir = wfd.cFileName;
-#endif
+ std::string strDir = wfd.fileName;
CFileItemPtr pItem(new CFileItem(strDir));
pItem->SetPath(strRoot + strDir);
pItem->m_bIsFolder = false;
- pItem->m_dwSize = CUtil::ToInt64(wfd.nFileSizeHigh, wfd.nFileSizeLow);
+ pItem->m_dwSize = CUtil::ToInt64(wfd.fileSizeHigh, wfd.fileSizeLow);
FILETIME localTime;
- KODI::TIME::FileTimeToLocalFileTime(&wfd.ftLastWriteTime, &localTime);
+ KODI::TIME::FileTimeToLocalFileTime(&wfd.lastWriteTime, &localTime);
pItem->m_dateTime=localTime;
items.Add(pItem);
}
diff --git a/xbmc/filesystem/iso9660.cpp b/xbmc/filesystem/iso9660.cpp
index 9b4952f538..a33eb5b1d4 100644
--- a/xbmc/filesystem/iso9660.cpp
+++ b/xbmc/filesystem/iso9660.cpp
@@ -27,6 +27,7 @@ ISO9660
*/
+
#include "iso9660.h"
#include "IFile.h"
@@ -42,8 +43,11 @@ ISO9660
#else
#include "platform/win32/CharsetConverter.h"
#endif
-#include <stdlib.h>
+
#include <algorithm>
+#include <cstring>
+#include <stdlib.h>
+
#include <cdio/bytesex.h>
//#define _DEBUG_OUTPUT 1
@@ -619,10 +623,12 @@ struct iso_dirtree *iso9660::FindFolder(const char *Folder )
}
//******************************************************************************************************************
-HANDLE iso9660::FindFirstFile9660(const char *szLocalFolder, WIN32_FIND_DATA *wfdFile)
+HANDLE iso9660::FindFirstFile9660(const char* szLocalFolder, Win32FindData* wfdFile)
{
- if (m_info.ISO_HANDLE == nullptr) return static_cast<HANDLE>(nullptr);
- memset( wfdFile, 0, sizeof(WIN32_FIND_DATA));
+ if (!m_info.ISO_HANDLE)
+ return static_cast<HANDLE>(nullptr);
+
+ memset(wfdFile, 0, sizeof(Win32FindData));
m_searchpointer = FindFolder( szLocalFolder );
@@ -632,21 +638,17 @@ HANDLE iso9660::FindFirstFile9660(const char *szLocalFolder, WIN32_FIND_DATA *wf
if ( m_searchpointer )
{
-#ifdef TARGET_WINDOWS
- wcscpy_s(wfdFile->cFileName, MAX_PATH, KODI::PLATFORM::WINDOWS::ToW(m_searchpointer->name).c_str());
-#else
- strncpy(wfdFile->cFileName, m_searchpointer->name, sizeof(wfdFile->cFileName) - 1);
- wfdFile->cFileName[sizeof(wfdFile->cFileName) - 1] = '\0';
-#endif
+ std::strncpy(wfdFile->fileName, m_searchpointer->name, sizeof(wfdFile->fileName) - 1);
+ wfdFile->fileName[sizeof(wfdFile->fileName) - 1] = '\0';
if ( m_searchpointer->type == 2 )
- wfdFile->dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
+ wfdFile->fileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
- wfdFile->ftLastWriteTime = m_searchpointer->filetime;
- wfdFile->ftLastAccessTime = m_searchpointer->filetime;
- wfdFile->ftCreationTime = m_searchpointer->filetime;
+ wfdFile->lastWriteTime = m_searchpointer->filetime;
+ wfdFile->lastAccessTime = m_searchpointer->filetime;
+ wfdFile->creationTime = m_searchpointer->filetime;
- wfdFile->nFileSizeLow = m_searchpointer->Length;
+ wfdFile->fileSizeLow = m_searchpointer->Length;
return reinterpret_cast<HANDLE>(1);
}
}
@@ -654,30 +656,26 @@ HANDLE iso9660::FindFirstFile9660(const char *szLocalFolder, WIN32_FIND_DATA *wf
}
//******************************************************************************************************************
-int iso9660::FindNextFile( HANDLE szLocalFolder, WIN32_FIND_DATA *wfdFile )
+int iso9660::FindNextFile(HANDLE szLocalFolder, Win32FindData* wfdFile)
{
- memset( wfdFile, 0, sizeof(WIN32_FIND_DATA));
+ memset(wfdFile, 0, sizeof(Win32FindData));
if ( m_searchpointer )
m_searchpointer = m_searchpointer->next;
if ( m_searchpointer )
{
-#ifdef TARGET_WINDOWS
- wcscpy_s(wfdFile->cFileName, MAX_PATH, KODI::PLATFORM::WINDOWS::ToW(m_searchpointer->name).c_str());
-#else
- strncpy(wfdFile->cFileName, m_searchpointer->name, sizeof(wfdFile->cFileName) - 1);
- wfdFile->cFileName[sizeof(wfdFile->cFileName) - 1] = '\0';
-#endif
+ std::strncpy(wfdFile->fileName, m_searchpointer->name, sizeof(wfdFile->fileName) - 1);
+ wfdFile->fileName[sizeof(wfdFile->fileName) - 1] = '\0';
if ( m_searchpointer->type == 2 )
- wfdFile->dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
+ wfdFile->fileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
- wfdFile->ftLastWriteTime = m_searchpointer->filetime;
- wfdFile->ftLastAccessTime = m_searchpointer->filetime;
- wfdFile->ftCreationTime = m_searchpointer->filetime;
+ wfdFile->lastWriteTime = m_searchpointer->filetime;
+ wfdFile->lastAccessTime = m_searchpointer->filetime;
+ wfdFile->creationTime = m_searchpointer->filetime;
- wfdFile->nFileSizeLow = m_searchpointer->Length;
+ wfdFile->fileSizeLow = m_searchpointer->Length;
return 1;
}
@@ -718,7 +716,7 @@ HANDLE iso9660::OpenFile(const char *filename)
if (!pContext)
return INVALID_HANDLE_VALUE;
- WIN32_FIND_DATA fileinfo;
+ Win32FindData fileinfo;
char *pointer, *pointer2;
char work[512];
pContext->m_bUseMode2 = false;
@@ -739,16 +737,9 @@ HANDLE iso9660::OpenFile(const char *filename)
intptr_t loop = (intptr_t)FindFirstFile9660( work, &fileinfo );
-#ifdef TARGET_WINDOWS
- auto wpointer = KODI::PLATFORM::WINDOWS::ToW(pointer);
-#endif
while ( loop > 0)
{
-#ifdef TARGET_WINDOWS
- if (!_wcsicmp(fileinfo.cFileName, wpointer.c_str()))
-#else
- if ( !stricmp(fileinfo.cFileName, pointer ) )
-#endif
+ if (!std::strcmp(fileinfo.fileName, pointer))
loop = -1;
else
loop = FindNextFile( NULL, &fileinfo );
@@ -760,7 +751,7 @@ HANDLE iso9660::OpenFile(const char *filename)
}
pContext->m_dwCurrentBlock = m_searchpointer->Location;
- pContext->m_dwFileSize = m_info.curr_filesize = fileinfo.nFileSizeLow;
+ pContext->m_dwFileSize = m_info.curr_filesize = fileinfo.fileSizeLow;
pContext->m_pBuffer = new uint8_t[CIRC_BUFFER_SIZE * BUFFER_SIZE];
pContext->m_dwStartBlock = pContext->m_dwCurrentBlock;
pContext->m_dwFilePos = 0;
diff --git a/xbmc/filesystem/iso9660.h b/xbmc/filesystem/iso9660.h
index b119f9efd5..6290734102 100644
--- a/xbmc/filesystem/iso9660.h
+++ b/xbmc/filesystem/iso9660.h
@@ -145,6 +145,20 @@ struct iso_directories
};
#define MAX_ISO_FILES 30
+struct Win32FindData
+{
+ unsigned int fileAttributes;
+ FILETIME creationTime;
+ FILETIME lastAccessTime;
+ FILETIME lastWriteTime;
+ unsigned int fileSizeHigh;
+ unsigned int fileSizeLow;
+ unsigned int reserved0;
+ unsigned int reserved1;
+ char fileName[260];
+ char alternateFileName[14];
+};
+
class iso9660
{
public:
@@ -165,8 +179,8 @@ public:
iso9660( );
virtual ~iso9660( );
- HANDLE FindFirstFile9660(const char *szLocalFolder, WIN32_FIND_DATA *wfdFile );
- int FindNextFile( HANDLE szLocalFolder, WIN32_FIND_DATA *wfdFile );
+ HANDLE FindFirstFile9660(const char* szLocalFolder, Win32FindData* wfdFile);
+ int FindNextFile(HANDLE szLocalFolder, Win32FindData* wfdFile);
bool FindClose( HANDLE szLocalFolder );
DWORD SetFilePointer(HANDLE hFile, long lDistanceToMove, long* lpDistanceToMoveHigh, DWORD dwMoveMethod );
int64_t GetFileSize(HANDLE hFile);
diff --git a/xbmc/platform/posix/PlatformDefs.h b/xbmc/platform/posix/PlatformDefs.h
index 7da90c575c..373a22128c 100644
--- a/xbmc/platform/posix/PlatformDefs.h
+++ b/xbmc/platform/posix/PlatformDefs.h
@@ -171,20 +171,6 @@ typedef struct _FILETIME
DWORD dwHighDateTime;
} FILETIME, *PFILETIME, *LPFILETIME;
-typedef struct _WIN32_FIND_DATA
-{
- DWORD dwFileAttributes;
- FILETIME ftCreationTime;
- FILETIME ftLastAccessTime;
- FILETIME ftLastWriteTime;
- DWORD nFileSizeHigh;
- DWORD nFileSizeLow;
- DWORD dwReserved0;
- DWORD dwReserved1;
- char cFileName[260];
- char cAlternateFileName[14];
-} WIN32_FIND_DATA, *PWIN32_FIND_DATA, *LPWIN32_FIND_DATA;
-
#define FILE_ATTRIBUTE_DIRECTORY 0x00000010
#define FILE_BEGIN 0