From 5d7ef51b83380816ef8a3f9145740e6d0a5019bd Mon Sep 17 00:00:00 2001 From: cxl Date: Wed, 8 Apr 2009 17:56:12 +0000 Subject: [PATCH] Minor changes git-svn-id: svn://ultimatepp.org/upp/trunk@1053 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Core/Path.cpp | 28 ++++++++++++++++++++++++++++ uppsrc/Core/Path.h | 1 + uppsrc/Draw/ImageOp.h | 2 +- uppsrc/Draw/ImageScale.cpp | 7 +++++-- uppsrc/Painter/Painter.h | 2 +- uppsrc/plugin/jpg/jpg.h | 1 - 6 files changed, 36 insertions(+), 5 deletions(-) diff --git a/uppsrc/Core/Path.cpp b/uppsrc/Core/Path.cpp index 669c509fb..e369d305d 100644 --- a/uppsrc/Core/Path.cpp +++ b/uppsrc/Core/Path.cpp @@ -799,6 +799,34 @@ Time FileGetTime(const char *filename) #endif//PLATFORM } +FileTime GetFileTime(const char *filename) +{ +#if defined(PLATFORM_WIN32) + HANDLE handle; + if(IsWinNT()) + handle = UnicodeWin32().CreateFileW(ToSystemCharsetW(filename), GENERIC_READ, + FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); + else + handle = CreateFile(ToSystemCharset(filename), GENERIC_READ, + FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); + FileTime ft0; + memset(&ft0, 0, sizeof(ft0)); + if(handle == INVALID_HANDLE_VALUE) + return ft0; + FileTime ft; + bool res = GetFileTime(handle, 0, 0, &ft); + CloseHandle(handle); + return res ? ft : ft0; +#elif defined(PLATFORM_POSIX) + struct stat st; + if(stat(ToSystemCharset(filename), &st)) + return 0; + return st.st_mtime; +#else + #error +#endif//PLATFORM +} + bool SetFileTime(const char *filename, FileTime ft) { #if defined(PLATFORM_WIN32) diff --git a/uppsrc/Core/Path.h b/uppsrc/Core/Path.h index a917a1173..baae2a363 100644 --- a/uppsrc/Core/Path.h +++ b/uppsrc/Core/Path.h @@ -157,6 +157,7 @@ bool FileExists(const char *path); bool DirectoryExists(const char *path); struct Time; +FileTime GetFileTime(const char *path); Time FileGetTime(const char *path); bool SetFileTime(const char *path, FileTime ft); bool FileSetTime(const char *path, Time time); diff --git a/uppsrc/Draw/ImageOp.h b/uppsrc/Draw/ImageOp.h index 5f9667a55..e15e67cf8 100644 --- a/uppsrc/Draw/ImageOp.h +++ b/uppsrc/Draw/ImageOp.h @@ -68,7 +68,7 @@ public: void DrawRasterData(Draw& w, int x, int y, int cx, int cy, const String& data); -void Rescale(RasterEncoder& tgt, Size sz, Raster& src, const Rect& src_rc, +bool Rescale(RasterEncoder& tgt, Size sz, Raster& src, const Rect& src_rc, Gate2 progress = false); Image Rescale(const Image& src, Size sz, const Rect& src_rc, Gate2 progress = false); Image Rescale(const Image& src, Size sz, Gate2 progress = false); diff --git a/uppsrc/Draw/ImageScale.cpp b/uppsrc/Draw/ImageScale.cpp index bacd39b5a..216b0489a 100644 --- a/uppsrc/Draw/ImageScale.cpp +++ b/uppsrc/Draw/ImageScale.cpp @@ -473,16 +473,19 @@ void RescaleImage::Get(RGBA *tgt) } } -void Rescale(RasterEncoder& tgt, Size tsz, Raster& src, const Rect& src_rc, +bool Rescale(RasterEncoder& tgt, Size tsz, Raster& src, const Rect& src_rc, Gate2 progress) { tgt.Create(tsz, src); RescaleImage rs; rs.Create(tsz, src, src_rc); - for(int i = 0; i < tsz.cy && !progress(i, tsz.cy); i++) { + for(int i = 0; i < tsz.cy; i++) { + if(progress(i, tsz.cy)) + return false; rs.Get(tgt); tgt.WriteLine(); } + return true; } Image Rescale(const Image& src, Size sz, const Rect& src_rc, Gate2 progress) diff --git a/uppsrc/Painter/Painter.h b/uppsrc/Painter/Painter.h index 3235b0f0f..2498429d8 100644 --- a/uppsrc/Painter/Painter.h +++ b/uppsrc/Painter/Painter.h @@ -3,7 +3,7 @@ #include -#define PAINTER_TIMING(x) RTIMING(x) +#define PAINTER_TIMING(x) // RTIMING(x) NAMESPACE_UPP diff --git a/uppsrc/plugin/jpg/jpg.h b/uppsrc/plugin/jpg/jpg.h index 52c8a7ecd..cf32f11e8 100644 --- a/uppsrc/plugin/jpg/jpg.h +++ b/uppsrc/plugin/jpg/jpg.h @@ -3,7 +3,6 @@ #include - NAMESPACE_UPP class JPGRaster : public StreamRaster {