Replace custom platform defines with standard ones

master
Daniel Kamil Kozar 2019-12-08 16:31:56 +01:00
parent 8cab740da9
commit 6bc34a6e54
No known key found for this signature in database
GPG Key ID: A5FB0175B3A93F03
22 changed files with 59 additions and 76 deletions

View File

@ -5,7 +5,7 @@
#include <errno.h>
#include <sstream>
#ifdef WIN32
#ifdef _WIN32
#include <windows.h>
#else
#include <stddef.h>
@ -19,19 +19,9 @@
using namespace std;
#ifdef SOLARIS
typedef struct mydirent
{
ino_t d_ino; /* "inode number" of entry */
off_t d_off; /* offset of disk directory entry */
unsigned short d_reclen; /* length of this record */
char d_name[PATH_MAX]; /* name of file */
} mydirent_t;
#endif
char getDirSeparator()
{
#ifdef WIN32
#ifdef _WIN32
return '\\';
#else
return '/';
@ -43,7 +33,7 @@ string extractFileDir( const string& fileName )
size_t index = fileName.find_last_of('/');
if( index != string::npos )
return fileName.substr( 0, index+1 );
#ifdef WIN32
#ifdef _WIN32
index = fileName.find_last_of('\\');
if( index != string::npos )
return fileName.substr( 0, index+1 );
@ -55,10 +45,10 @@ string extractFileDir( const string& fileName )
bool fileExists( const string& fileName )
{
bool fileExists = false;
#ifdef WIN32
#ifdef _WIN32
struct _stat64 buf;
fileExists = _stat64( fileName.c_str(), &buf ) == 0;
#else // LINUX
#else
struct stat64 buf;
fileExists = stat64( fileName.c_str(), &buf ) == 0;
#endif
@ -69,10 +59,10 @@ bool fileExists( const string& fileName )
uint64_t getFileSize ( const std::string& fileName )
{
bool res = false;
#ifdef WIN32
#ifdef _WIN32
struct _stat64 fileStat;
res = _stat64( fileName.c_str(), &fileStat ) == 0;
#else // LINUX
#else
struct stat64 fileStat;
res = stat64( fileName.c_str(), &fileStat ) == 0;
#endif
@ -98,13 +88,13 @@ bool createDir(
if( dirEnd != string::npos )
{
string parentDir = dirName.substr( 0, dirEnd );
#if defined(LINUX) || defined(SOLARIS) || defined(MAC)
#if __linux__ == 1 || (defined(__APPLE__) && defined(__MACH__))
if( mkdir( parentDir.c_str(), S_IREAD | S_IWRITE | S_IEXEC ) == -1 )
{
if( errno != EEXIST )
return false;
}
#elif defined(WIN32)
#elif defined(_WIN32)
if (parentDir.size() == 0 || parentDir[parentDir.size()-1] == ':' ||
parentDir == string("\\\\.") || parentDir == string("\\\\.\\") || // UNC patch prefix
(strStartWith(parentDir, "\\\\.\\") && parentDir[parentDir.size()-1] == '}')) // UNC patch prefix
@ -119,16 +109,16 @@ bool createDir(
}
}
#if defined(LINUX) || defined(SOLARIS) || defined(MAC)
#if __linux__ == 1 || (defined(__APPLE__) && defined(__MACH__))
return mkdir( dirName.c_str(), S_IREAD | S_IWRITE | S_IEXEC ) == 0;
#elif defined(WIN32)
#elif defined(_WIN32)
return CreateDirectory( dirName.c_str(), 0 ) != 0;
#endif
}
bool deleteFile( const string& fileName )
{
#if defined(LINUX) || defined(SOLARIS) || defined(MAC)
#if __linux__ == 1 || (defined(__APPLE__) && defined(__MACH__))
return unlink( fileName.c_str() ) == 0;
#else
if( DeleteFile(fileName.c_str()) )
@ -147,7 +137,7 @@ bool deleteFile( const string& fileName )
//-----------------------------------------------------------------------------
#if defined(WIN32)
#if defined(_WIN32)
/** windows implementation */
//-----------------------------------------------------------------------------
#include <windows.h>
@ -205,7 +195,7 @@ bool findDirs(
return true;
}
#elif defined(LINUX) || defined(MAC)
#elif __linux__ == 1 || (defined(__APPLE__) && defined(__MACH__))
#include <fnmatch.h>
bool findFiles(

View File

@ -5,7 +5,7 @@
#include <fcntl.h>
#include "../types/types.h"
#ifdef WIN32
#ifdef _WIN32
#pragma warning( disable : 4290 )
#endif

View File

@ -14,7 +14,7 @@
#include <string.h>
#include <stdlib.h>
#ifdef MAC
#if defined(__APPLE__) && defined(__MACH__)
#define O_LARGEFILE 0
#endif
@ -159,7 +159,7 @@ uint64_t File::seek( int64_t offset, SeekMethod whence )
break;
}
m_pos = offset;
#ifdef MAC
#if defined(__APPLE__) && defined(__MACH__)
return lseek( (long)m_impl, offset, sWhence );
#else
return lseek64( (long)m_impl, offset, sWhence );
@ -168,7 +168,7 @@ uint64_t File::seek( int64_t offset, SeekMethod whence )
bool File::truncate( uint64_t newFileSize )
{
#ifdef MAC
#if defined(__APPLE__) && defined(__MACH__)
return ftruncate( (long)m_impl, newFileSize ) == 0;
#else
return ftruncate64( (long)m_impl, newFileSize ) == 0;

View File

@ -6,7 +6,7 @@
#include <memory.h>
#include <ostream>
#ifndef WIN32
#ifndef _WIN32
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
@ -41,7 +41,7 @@ uint64_t my_htonll( const uint64_t& original )
// Simple types conversion
int64_t strToInt64( const char* const str )
{
#ifdef WIN32
#ifdef _WIN32
return _atoi64( str );
#else
return strtoll( str, 0, 10 );
@ -50,7 +50,7 @@ int64_t strToInt64( const char* const str )
uint64_t strToInt64u( const char* const str )
{
#ifdef WIN32
#ifdef _WIN32
return _atoi64( str );
#else
return strtoull( str, 0, 10 );

View File

@ -9,7 +9,7 @@
#define override
#ifdef WIN32
#ifdef _WIN32
#define strcasecmp stricmp
#endif
char* strnstr(const char *s1, const char *s2, size_t len);

View File

@ -4,7 +4,7 @@
#include "vod_common.h"
#include "vodCoreException.h"
#ifdef WIN32
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
@ -19,7 +19,7 @@ bool FileReaderData::openStream()
if ( !rez )
{
#ifdef WIN32
#ifdef _WIN32
char msgBuf [ 32*1024 ];
memset ( msgBuf, 0, sizeof(msgBuf) );

View File

@ -4,7 +4,7 @@
#include <string.h>
#include <stdlib.h>
#ifdef WIN32
#ifdef _WIN32
# include <time.h>
#endif

View File

@ -594,7 +594,7 @@ int main(int argc, char** argv)
LTRACE(LT_INFO, 2, "");
#ifdef WIN32
#ifdef _WIN32
char buffer[1024*16];
CharToOemA(itemName.c_str(), buffer);
LTRACE(LT_INFO, 2, "File #" << strPadLeft(int32ToStr(i),5,'0') << " name=" << buffer);
@ -752,7 +752,7 @@ int main(int argc, char** argv)
} catch(runtime_error& e) {
if (argc == 2)
LTRACE2(LT_ERROR, "Error: ");
#ifdef WIN32
#ifdef _WIN32
char buffer[1024*16];
CharToOemA(e.what(), buffer);
LTRACE(LT_ERROR, 2, buffer);
@ -763,7 +763,7 @@ int main(int argc, char** argv)
} catch(VodCoreException& e) {
if (argc == 2)
LTRACE2(LT_ERROR, "Error: ");
#ifdef WIN32
#ifdef _WIN32
char buffer[1024*16];
CharToOemA(e.m_errStr.c_str(), buffer);
LTRACE(LT_ERROR, 2, buffer);

View File

@ -1160,7 +1160,7 @@ void METADemuxer::updateReport(bool checkTime)
void METADemuxer::lineBack()
{
#ifdef WIN32
#ifdef _WIN32
HANDLE consoleOutput;
CONSOLE_SCREEN_BUFFER_INFO csbi;
consoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);

View File

@ -1,5 +1,5 @@
#ifndef WIN32
#ifndef _WIN32
#endif
#include <iostream>
#include "mpegStreamReader.h"

View File

@ -1,5 +1,5 @@
#ifndef WIN32
#ifndef _WIN32
#endif
#include <memory.h>
#include "mpegVideo.h"

View File

@ -1,6 +1,6 @@
#if !defined(WIN32) || defined(WIN32_DEBUG_FREETYPE)
#if !defined(_WIN32) || defined(WIN32_DEBUG_FREETYPE)
#ifdef WIN32
#ifdef _WIN32
#pragma comment(lib, "../../freetype/lib/freetype.lib")
#endif
@ -15,13 +15,11 @@
#include <map>
#include <algorithm>
#ifdef WIN32
#if defined(_WIN32)
const static char FONT_ROOT[] = "c:/WINDOWS/Fonts"; // for debug only
#endif
#ifdef LINUX
#elif __linux__ == 1
const static char FONT_ROOT[] = "/usr/share/fonts/";
#endif
#ifdef MAC
#elif defined(__APPLE__) && defined(__MACH__)
const static char FONT_ROOT[] = "/Library/Fonts/";
#endif

View File

@ -15,7 +15,7 @@ public:
struct BitmapInfo {
int Width;
int Height;
#ifdef WIN32
#ifdef _WIN32
RGBQUAD* buffer; // rgb triple buffer
#else
text_subtitles::RGBQUAD* buffer;

View File

@ -148,7 +148,7 @@ void SingleFileMuxer::openDstFile()
//if (!createDir(dstFileName, true))
// THROW(ERR_CANT_CREATE_FILE, "Can't create output directory " << dstFileName);
int systemFlags = 0;
#ifdef WIN32
#ifdef _WIN32
if (m_owner->isAsyncMode())
systemFlags += FILE_FLAG_NO_BUFFERING;
#endif
@ -198,7 +198,7 @@ void SingleFileMuxer::writeOutBuffer(StreamInfo* streamInfo)
streamInfo->m_part++;
int systemFlags = 0;
streamInfo->m_bufLen = 0;
#ifdef WIN32
#ifdef _WIN32
if (m_owner->isAsyncMode())
systemFlags += FILE_FLAG_NO_BUFFERING;
#endif

View File

@ -97,7 +97,7 @@ bool SRTStreamReader::detectSrcFormat(uint8_t* dataStart, int len, int& prefixLe
m_short_R = my_htons(0x0d00);
}
else {
#ifdef WIN32
#ifdef _WIN32
m_srcFormat = UtfConverter::sfANSI; // default value for win32
#else
//m_srcFormat = UtfConverter::sfDefault;

View File

@ -1,6 +1,6 @@
#include "textSubtitles.h"
#ifdef WIN32
#ifdef _WIN32
# include <winerror.h>
# include "osdep/textSubtitlesRenderWin32.h"
# ifdef WIN32_DEBUG_FREETYPE
@ -40,7 +40,7 @@ TextToPGSConverter::TextToPGSConverter(bool sourceIsText): /*TextSubtitlesRender
m_minLine = 0;
m_maxLine = 0;
if (sourceIsText) {
#ifdef WIN32
#ifdef _WIN32
#ifdef WIN32_DEBUG_FREETYPE
m_textRender = new TextSubtitlesRenderFT;
#else

View File

@ -1,7 +1,7 @@
#ifndef __TEXT_SUBTITLES_H
#define __TEXT_SUBTITLES_H
#ifdef WIN32
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include "windows.h"
#endif

View File

@ -5,7 +5,7 @@
#include <map>
#include <types/types.h>
#ifdef WIN32
#ifdef _WIN32
#include "windows.h"
#endif
@ -15,7 +15,7 @@ namespace text_subtitles
const static int DEFAULT_BROWSER_STYLE_FS = 3;
const static double BROWSER_FONT_STYLE_INC_COEFF = 1.4142135623730950488016887242097; // example: font 2 > font1 to 20%
#ifndef WIN32
#ifndef _WIN32
struct RGBQUAD {
uint8_t rgbBlue;
uint8_t rgbGreen;

View File

@ -17,7 +17,7 @@
#include <fs/textfile.h>
#include "iso_writer.h"
#ifdef WIN32
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
@ -1376,7 +1376,7 @@ void TSMuxer::openDstFile()
m_muxFile = m_fileFactory ? m_fileFactory->createFile() : new File();
int systemFlags = 0;
#ifdef WIN32
#ifdef _WIN32
if (m_owner->isAsyncMode())
systemFlags += FILE_FLAG_NO_BUFFERING;
#endif

View File

@ -1,5 +1,5 @@
#ifndef WIN32
#ifndef _WIN32
#endif
#include "tsPacket.h"
#include "bitStream.h"

View File

@ -6,7 +6,7 @@
#include "vod_common.h"
#include "memory.h"
#ifdef WIN32
#ifdef _WIN32
#include <windows.h>
#else
#include <locale.h>
@ -70,7 +70,7 @@ namespace UtfConverter
{
if (widesize == 0)
return L"";
#ifdef WIN32
#if defined(_WIN32)
else if (srcFormat == sfANSI)
{
wchar_t* widestringnative = new wchar_t[widesize+1];
@ -80,8 +80,7 @@ namespace UtfConverter
delete [] widestringnative;
return resultstring;
}
#endif
#ifdef LINUX
#elif __linux__ == 1
/*
else if (srcFormat == sfDefault)
{

View File

@ -7,10 +7,6 @@
#include <QSettings>
#include <QUrl>
#ifdef WIN32
#include "windows.h"
#endif
const char fileDialogFilter[] =
"All supported media files (*.aac *.mpv *.mpa *.avc *.mvc *.264 *.h264 *.ac3 *.dts *.ts *.m2ts *.mts *.ssif *.mpg *.mpeg *.vob *.evo *.mkv *.mka *.mks *.mp4 *.m4a *.mov *.sup *.wav *.w64 *.pcm *.m1v *.m2v *.vc1 *.hevc *.hvc *.265 *.h265 *.mpls *.mpl *.srt);;\
AC3/E-AC3 (*.ac3 *.ddp);;\