diff options
author | eray orçunus <erayorcunus@gmail.com> | 2020-10-12 19:30:49 +0200 |
---|---|---|
committer | eray orçunus <erayorcunus@gmail.com> | 2020-10-12 19:41:13 +0200 |
commit | 3772be32bfeaee65de4ca1464786caa50ed30861 (patch) | |
tree | 556cd4f4471b1fea8673fb1d97ea0a7de58e67b2 | |
parent | Some unicode funcs belong to Font.cpp + small fix (diff) | |
download | re3-3772be32bfeaee65de4ca1464786caa50ed30861.tar re3-3772be32bfeaee65de4ca1464786caa50ed30861.tar.gz re3-3772be32bfeaee65de4ca1464786caa50ed30861.tar.bz2 re3-3772be32bfeaee65de4ca1464786caa50ed30861.tar.lz re3-3772be32bfeaee65de4ca1464786caa50ed30861.tar.xz re3-3772be32bfeaee65de4ca1464786caa50ed30861.tar.zst re3-3772be32bfeaee65de4ca1464786caa50ed30861.zip |
-rw-r--r-- | src/core/CdStreamPosix.cpp | 17 | ||||
-rw-r--r-- | src/skel/crossplatform.cpp | 25 |
2 files changed, 28 insertions, 14 deletions
diff --git a/src/core/CdStreamPosix.cpp b/src/core/CdStreamPosix.cpp index a6ab62bc..fdc63a05 100644 --- a/src/core/CdStreamPosix.cpp +++ b/src/core/CdStreamPosix.cpp @@ -240,9 +240,8 @@ CdStreamRead(int32 channel, void *buffer, uint32 offset, uint32 size) CdReadInfo *pChannel = &gpReadInfo[channel]; ASSERT( pChannel != nil ); - if ( pChannel->nSectorsToRead != 0 || pChannel->bReading ) { - if (pChannel->nSectorOffset == _GET_OFFSET(offset) && pChannel->nSectorsToRead >= size) + if (pChannel->hFile == hImage - 1 && pChannel->nSectorOffset == _GET_OFFSET(offset) && pChannel->nSectorsToRead >= size) return STREAM_SUCCESS; flushStream[channel] = 1; @@ -293,7 +292,6 @@ CdStreamGetStatus(int32 channel) if ( pChannel->nStatus != STREAM_NONE ) { int32 status = pChannel->nStatus; - pChannel->nStatus = STREAM_NONE; return status; @@ -322,15 +320,16 @@ CdStreamSync(int32 channel) pthread_kill(pChannel->pChannelThread, SIGUSR1); if (pChannel->bReading) { pChannel->bLocked = true; - sem_wait(pChannel->pDoneSemaphore); + while (pChannel->bLocked) + sem_wait(pChannel->pDoneSemaphore); } #else pChannel->nSectorsToRead = 0; if (pChannel->bReading) { pChannel->bLocked = true; pthread_kill(_gCdStreamThread, SIGUSR1); - sem_wait(pChannel->pDoneSemaphore); - + while (pChannel->bLocked) + sem_wait(pChannel->pDoneSemaphore); } #endif pChannel->bReading = false; @@ -341,8 +340,8 @@ CdStreamSync(int32 channel) if ( pChannel->nSectorsToRead != 0 ) { pChannel->bLocked = true; - - sem_wait(pChannel->pDoneSemaphore); + while (pChannel->bLocked) + sem_wait(pChannel->pDoneSemaphore); } pChannel->bReading = false; @@ -443,9 +442,9 @@ void *CdStreamThread(void *param) #endif pChannel->nSectorsToRead = 0; - if ( pChannel->bLocked ) { + pChannel->bLocked = 0; sem_post(pChannel->pDoneSemaphore); } pChannel->bReading = false; diff --git a/src/skel/crossplatform.cpp b/src/skel/crossplatform.cpp index 452ad9fa..ac4bbe85 100644 --- a/src/skel/crossplatform.cpp +++ b/src/skel/crossplatform.cpp @@ -27,13 +27,28 @@ void GetLocalTime_CP(SYSTEMTIME *out) { #ifndef _WIN32 HANDLE FindFirstFile(const char* pathname, WIN32_FIND_DATA* firstfile) { char newpathname[32]; + strncpy(newpathname, pathname, 32); - char* path = strtok(newpathname, "\\*"); + char* path = strtok(newpathname, "*"); + + // Case-sensitivity and backslashes... + char *real = casepath(path); + if (real) { + real[strlen(real)] = '*'; + char *extension = strtok(NULL, "*"); + if (extension) + strcat(real, extension); + + strncpy(newpathname, real, 32); + free(real); + path = strtok(newpathname, "*"); + } + strncpy(firstfile->folder, path, sizeof(firstfile->folder)); // Both w/ extension and w/o extension is ok - if (strlen(path) + 2 != strlen(pathname)) - strncpy(firstfile->extension, strtok(NULL, "\\*"), sizeof(firstfile->extension)); + if (strlen(path) + 1 != strlen(pathname)) + strncpy(firstfile->extension, strtok(NULL, "*"), sizeof(firstfile->extension)); else strncpy(firstfile->extension, "", sizeof(firstfile->extension)); @@ -52,8 +67,8 @@ bool FindNextFile(HANDLE d, WIN32_FIND_DATA* finddata) { while ((file = readdir((DIR*)d)) != NULL) { // We only want "DT_REG"ular Files, but reportedly some FS and OSes gives DT_UNKNOWN as type. - if ((file->d_type == DT_UNKNOWN || file->d_type == DT_REG) && - (extensionLen == 0 || strncmp(&file->d_name[strlen(file->d_name) - extensionLen], finddata->extension, extensionLen) == 0)) { + if ((file->d_type == DT_UNKNOWN || file->d_type == DT_REG || file->d_type == DT_LNK) && + (extensionLen == 0 || strncasecmp(&file->d_name[strlen(file->d_name) - extensionLen], finddata->extension, extensionLen) == 0)) { sprintf(relativepath, "%s/%s", finddata->folder, file->d_name); realpath(relativepath, path); |