[SCM] exiv2 packaging branch, master, updated. debian/0.25-3.1-3734-gdcbc29a
Maximiliano Curia
maxy at moszumanska.debian.org
Thu Jul 13 17:43:12 UTC 2017
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/exiv2.git;a=commitdiff;h=86efaac
The following commit has been merged in the master branch:
commit 86efaac7908c9e6e8d8fc04bbc97dc8e49d8c235
Author: Robin Mills <robin at clanmills.com>
Date: Thu Jul 12 04:40:31 2012 +0000
Adding typeFile detector to geotag.cpp and cosmetic changes to directory code.
---
samples/geotag.cpp | 87 +++++++++++++++++++++++++++++++++++-------------------
1 file changed, 56 insertions(+), 31 deletions(-)
diff --git a/samples/geotag.cpp b/samples/geotag.cpp
index 5f4bf59..8876027 100644
--- a/samples/geotag.cpp
+++ b/samples/geotag.cpp
@@ -39,8 +39,9 @@ enum
, typeDirectory = 1
, typeImage = 2
, typeXML = 3
+, typeFile = 4
};
-static const char* types[] = { "unknown" , "directory" , "image" , "xml" };
+static const char* types[] = { "unknown" , "directory" , "image" , "xml" ,"file" };
class UserData
{
@@ -72,8 +73,41 @@ static void endElement(void* userData, const char* name)
bool readDir(char* path,strings_t& paths)
{
-#ifndef _MSC_VER
+ paths.empty();
bool bResult = false;
+#ifdef _MSC_VER
+ DWORD attrs = GetFileAttributes(path);
+ bool bOKAttrs = attrs != INVALID_FILE_ATTRIBUTES;
+ bool bIsDir = (attrs & FILE_ATTRIBUTE_DIRECTORY) ? true : false ;
+
+ if( bOKAttrs && bIsDir ) {
+ bResult = true ;
+
+ char search[_MAX_PATH+10];
+ strcpy_s(search,_MAX_PATH,path);
+ strcat_s(search,_MAX_PATH,"\*");
+
+ WIN32_FIND_DATA ffd;
+ HANDLE hFind = FindFirstFile(search, &ffd);
+ BOOL bGo = hFind != INVALID_HANDLE_VALUE;
+
+ if ( bGo ) {
+ while ( bGo ) {
+ if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ {
+ // _tprintf(TEXT(" %s <DIR>
"), ffd.cFileName);
+ }
+ else
+ {
+ paths.push_back( std::string(ffd.cFileName));
+ printf("-> %s
",ffd.cFileName);
+ }
+ bGo = FindNextFile(hFind, &ffd) != 0;
+ }
+ CloseHandle(hFind);
+ }
+ }
+#else
DIR* dir = opendir (path);
if (dir != NULL)
{
@@ -88,35 +122,6 @@ bool readDir(char* path,strings_t& paths)
}
closedir (dir);
}
-#else
- bool bResult = (GetFileAttributesA(path) & FILE_ATTRIBUTE_DIRECTORY)!= 0L ;
- if ( bResult ) {
- char search[_MAX_PATH+10];
- strcpy_s(search,_MAX_PATH,path);
- strcat_s(search,_MAX_PATH,"\*");
-
- WIN32_FIND_DATA ffd;
- HANDLE hFind = FindFirstFile(search, &ffd);
- BOOL bGo = hFind != INVALID_HANDLE_VALUE;
- while ( bGo ) {
- if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- {
- // _tprintf(TEXT(" %s <DIR>
"), ffd.cFileName);
- // count++ ;
- }
- else // if ( ffd.dwFileAttributes & FILE_ATTRIBUTE_NORMAL)
- {
-// filesize.LowPart = ffd.nFileSizeLow;
-// filesize.HighPart = ffd.nFileSizeHigh;
-// _tprintf(TEXT(" %s %ld bytes
"), ffd.cFileName, filesize.QuadPart);
- paths.push_back( std::string(ffd.cFileName));
- printf("-> %s
",ffd.cFileName);
- }
- bGo = FindNextFile(hFind, &ffd) != 0;
- }
-
- CloseHandle(hFind);
- }
#endif
return bResult ;
}
@@ -157,6 +162,20 @@ bool readXML(char* path,size_t& count)
return bResult ;
}
+bool readFile(char* path,size_t& count)
+{
+ FILE* f = fopen(path,"r");
+ bool bResult = f ? true : false;
+ if ( bResult ) {
+ fseek(f,0L,SEEK_END);
+ count = ftell(f);
+ }
+ if ( f ) fclose(f) ;
+
+ return bResult ;
+}
+
+
int main(int argc, char* const argv[])
{
if ( argc < 2 ) {
@@ -195,6 +214,12 @@ int main(int argc, char* const argv[])
}
} catch (Exiv2::Error& ) {};
+ if ( fileType == typeUnknown ) {
+ if ( readFile(arg,count) ) {
+ if ( count ) fileType = typeFile ;
+ }
+ }
+
printf("arg:%s type:%s count:%d
",arg,types[fileType],count); ;
}
--
exiv2 packaging
More information about the pkg-kde-commits
mailing list