From 17040ecd02388f94af222cd7fbadc283a4240e27 Mon Sep 17 00:00:00 2001 From: Julian Storer Date: Fri, 21 Jan 2011 17:50:32 +0000 Subject: [PATCH] Posix file-time-setting fix. Warning removal for intel compiler. --- amalgamation/juce_amalgamated_template.cpp | 4 +- .../juce demo/Source/ApplicationStartup.cpp | 2 +- extras/juce demo/Source/demos/OpenGLDemo.cpp | 10 ++-- extras/juce demo/Source/jucedemo_headers.h | 2 +- juce.h | 3 ++ juce_amalgamated.cpp | 52 +++++++++++++------ juce_amalgamated.h | 6 ++- .../components/windows/juce_ComponentPeer.h | 3 +- src/native/common/juce_posix_SharedCode.h | 22 +++++--- .../windows/juce_win32_NativeIncludes.h | 4 ++ 10 files changed, 72 insertions(+), 36 deletions(-) diff --git a/amalgamation/juce_amalgamated_template.cpp b/amalgamation/juce_amalgamated_template.cpp index 303c2c7261..5a3d3fd317 100644 --- a/amalgamation/juce_amalgamated_template.cpp +++ b/amalgamation/juce_amalgamated_template.cpp @@ -65,7 +65,7 @@ #include "../src/native/windows/juce_win32_NativeIncludes.h" #elif JUCE_LINUX #include "../src/native/linux/juce_linux_NativeIncludes.h" - #elif JUCE_MAC || JUCE_IPHONE + #elif JUCE_MAC || JUCE_IOS #include "../src/native/mac/juce_mac_NativeIncludes.h" #else #error "Unknown platform!" @@ -405,7 +405,7 @@ #include "../src/native/linux/juce_linux_NativeCode.cpp" #endif - #if JUCE_MAC || JUCE_IPHONE + #if JUCE_MAC || JUCE_IOS #include "../src/native/mac/juce_mac_NativeCode.mm" #endif #endif diff --git a/extras/juce demo/Source/ApplicationStartup.cpp b/extras/juce demo/Source/ApplicationStartup.cpp index ec1f4e0be8..6c3b88c360 100644 --- a/extras/juce demo/Source/ApplicationStartup.cpp +++ b/extras/juce demo/Source/ApplicationStartup.cpp @@ -43,7 +43,7 @@ public: //============================================================================== void initialise (const String& /*commandLine*/) { - #if JUCE_IPHONE + #if JUCE_IOS theMainWindow.setVisible (true); theMainWindow.setFullScreen (true); #else diff --git a/extras/juce demo/Source/demos/OpenGLDemo.cpp b/extras/juce demo/Source/demos/OpenGLDemo.cpp index ada5344a7f..ed839103cb 100644 --- a/extras/juce demo/Source/demos/OpenGLDemo.cpp +++ b/extras/juce demo/Source/demos/OpenGLDemo.cpp @@ -38,12 +38,12 @@ #include #include #undef KeyPress -#elif JUCE_IPHONE +#elif JUCE_IOS #include #include #elif JUCE_MAC #include -#elif JUCE_IPHONE +#elif JUCE_IOS //#include #endif @@ -60,7 +60,7 @@ public: : rotation (0.0f), delta (1.0f) { -#if JUCE_IPHONE +#if JUCE_IOS // (On the iPhone, choose a format without a depth buffer) setPixelFormat (OpenGLPixelFormat (8, 8, 0, 0)); #endif @@ -109,7 +109,7 @@ public: // we'll use the opportunity to create the textures needed. void newOpenGLContextCreated() { -#if ! JUCE_IPHONE +#if ! JUCE_IOS // (no need to call makeCurrentContextActive(), as that will have // been done for us before the method call). glClearColor (0.0f, 0.0f, 0.0f, 0.0f); @@ -154,7 +154,7 @@ public: glMatrixMode (GL_PROJECTION); glLoadIdentity(); -#if JUCE_IPHONE +#if JUCE_IOS const GLfloat vertices[] = { -0.5f, -0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f, 0.5f }; const GLubyte colours[] = { 255, 255, 0, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 0, 255, 255 }; diff --git a/extras/juce demo/Source/jucedemo_headers.h b/extras/juce demo/Source/jucedemo_headers.h index e8903eca0c..518c63ca66 100644 --- a/extras/juce demo/Source/jucedemo_headers.h +++ b/extras/juce demo/Source/jucedemo_headers.h @@ -29,7 +29,7 @@ // include the JUCE headers.. #include "../JuceLibraryCode/JuceHeader.h" -#if JUCE_IPHONE || JUCE_LINUX +#if JUCE_IOS || JUCE_LINUX #undef JUCE_USE_CAMERA #endif diff --git a/juce.h b/juce.h index d9cd385d88..a41c379421 100644 --- a/juce.h +++ b/juce.h @@ -54,6 +54,9 @@ BEGIN_JUCE_NAMESPACE #pragma pack (push, 8) #pragma warning (push) #pragma warning (disable: 4786) // (old vc6 warning about long class names) + #ifdef __INTEL_COMPILER + #pragma warning (disable: 1125) + #endif #endif // this is where all the class header files get brought in.. diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 30139fd987..edfcd7a83f 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -497,6 +497,10 @@ #if JUCE_MSVC #pragma warning (push) #pragma warning (disable : 4100 4201 4514 4312 4995) + + #ifdef __INTEL_COMPILER + #pragma warning (disable: 1125) + #endif #endif #define _WIN32_WINNT 0x0500 @@ -849,7 +853,7 @@ protected: /*** End of inlined file: juce_linux_NativeIncludes.h ***/ - #elif JUCE_MAC || JUCE_IPHONE + #elif JUCE_MAC || JUCE_IOS /*** Start of inlined file: juce_mac_NativeIncludes.h ***/ #ifndef __JUCE_MAC_NATIVEINCLUDES_JUCEHEADER__ @@ -254122,21 +254126,29 @@ void File::getFileTimesInternal (int64& modificationTime, int64& accessTime, int bool File::setFileTimesInternal (int64 modificationTime, int64 accessTime, int64 /*creationTime*/) const { - struct utimbuf times; - times.actime = (time_t) (accessTime / 1000); - times.modtime = (time_t) (modificationTime / 1000); + juce_statStruct info; - return utime (fullPath.toUTF8(), ×) == 0; + if ((modificationTime != 0 || accessTime != 0) && juce_stat (fullPath, info)) + { + struct utimbuf times; + times.actime = accessTime != 0 ? (time_t) (accessTime / 1000) : info.st_atime; + times.modtime = modificationTime != 0 ? (time_t) (modificationTime / 1000) : info.st_mtime; + + return utime (fullPath.toUTF8(), ×) == 0; + } + + return false; } bool File::deleteFile() const { if (! exists()) return true; - else if (isDirectory()) + + if (isDirectory()) return rmdir (fullPath.toUTF8()) == 0; - else - return remove (fullPath.toUTF8()) == 0; + + return remove (fullPath.toUTF8()) == 0; } bool File::moveInternal (const File& dest) const @@ -262520,7 +262532,7 @@ END_JUCE_NAMESPACE #endif - #if JUCE_MAC || JUCE_IPHONE + #if JUCE_MAC || JUCE_IOS /*** Start of inlined file: juce_mac_NativeCode.mm ***/ /* @@ -264001,21 +264013,29 @@ void File::getFileTimesInternal (int64& modificationTime, int64& accessTime, int bool File::setFileTimesInternal (int64 modificationTime, int64 accessTime, int64 /*creationTime*/) const { - struct utimbuf times; - times.actime = (time_t) (accessTime / 1000); - times.modtime = (time_t) (modificationTime / 1000); + juce_statStruct info; + + if ((modificationTime != 0 || accessTime != 0) && juce_stat (fullPath, info)) + { + struct utimbuf times; + times.actime = accessTime != 0 ? (time_t) (accessTime / 1000) : info.st_atime; + times.modtime = modificationTime != 0 ? (time_t) (modificationTime / 1000) : info.st_mtime; + + return utime (fullPath.toUTF8(), ×) == 0; + } - return utime (fullPath.toUTF8(), ×) == 0; + return false; } bool File::deleteFile() const { if (! exists()) return true; - else if (isDirectory()) + + if (isDirectory()) return rmdir (fullPath.toUTF8()) == 0; - else - return remove (fullPath.toUTF8()) == 0; + + return remove (fullPath.toUTF8()) == 0; } bool File::moveInternal (const File& dest) const diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 44c0e0f2b5..6ac659d052 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -3349,6 +3349,9 @@ BEGIN_JUCE_NAMESPACE #pragma pack (push, 8) #pragma warning (push) #pragma warning (disable: 4786) // (old vc6 warning about long class names) + #ifdef __INTEL_COMPILER + #pragma warning (disable: 1125) + #endif #endif // this is where all the class header files get brought in.. @@ -60739,8 +60742,7 @@ public: For keycode info, see the KeyPress class. Returns true if the keystroke was used. */ - bool handleKeyPress (int keyCode, - juce_wchar textCharacter); + bool handleKeyPress (int keyCode, juce_wchar textCharacter); /** Called whenever a key is pressed or released. Returns true if the keystroke was used. diff --git a/src/gui/components/windows/juce_ComponentPeer.h b/src/gui/components/windows/juce_ComponentPeer.h index 45968d7a78..7162b69b0e 100644 --- a/src/gui/components/windows/juce_ComponentPeer.h +++ b/src/gui/components/windows/juce_ComponentPeer.h @@ -270,8 +270,7 @@ public: For keycode info, see the KeyPress class. Returns true if the keystroke was used. */ - bool handleKeyPress (int keyCode, - juce_wchar textCharacter); + bool handleKeyPress (int keyCode, juce_wchar textCharacter); /** Called whenever a key is pressed or released. Returns true if the keystroke was used. diff --git a/src/native/common/juce_posix_SharedCode.h b/src/native/common/juce_posix_SharedCode.h index 81b2df7eb9..8ff043f55c 100644 --- a/src/native/common/juce_posix_SharedCode.h +++ b/src/native/common/juce_posix_SharedCode.h @@ -347,21 +347,29 @@ void File::getFileTimesInternal (int64& modificationTime, int64& accessTime, int bool File::setFileTimesInternal (int64 modificationTime, int64 accessTime, int64 /*creationTime*/) const { - struct utimbuf times; - times.actime = (time_t) (accessTime / 1000); - times.modtime = (time_t) (modificationTime / 1000); + juce_statStruct info; + + if ((modificationTime != 0 || accessTime != 0) && juce_stat (fullPath, info)) + { + struct utimbuf times; + times.actime = accessTime != 0 ? (time_t) (accessTime / 1000) : info.st_atime; + times.modtime = modificationTime != 0 ? (time_t) (modificationTime / 1000) : info.st_mtime; + + return utime (fullPath.toUTF8(), ×) == 0; + } - return utime (fullPath.toUTF8(), ×) == 0; + return false; } bool File::deleteFile() const { if (! exists()) return true; - else if (isDirectory()) + + if (isDirectory()) return rmdir (fullPath.toUTF8()) == 0; - else - return remove (fullPath.toUTF8()) == 0; + + return remove (fullPath.toUTF8()) == 0; } bool File::moveInternal (const File& dest) const diff --git a/src/native/windows/juce_win32_NativeIncludes.h b/src/native/windows/juce_win32_NativeIncludes.h index 6ceb41ba49..e8ac941fab 100644 --- a/src/native/windows/juce_win32_NativeIncludes.h +++ b/src/native/windows/juce_win32_NativeIncludes.h @@ -41,6 +41,10 @@ #if JUCE_MSVC #pragma warning (push) #pragma warning (disable : 4100 4201 4514 4312 4995) + + #ifdef __INTEL_COMPILER + #pragma warning (disable: 1125) + #endif #endif #define _WIN32_WINNT 0x0500