Revision: 184
http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=184&view=rev
Author: rorthomas
Date: 2009-04-19 22:53:13 +0000 (Sun, 19 Apr 2009)
Log Message:
-----------
wsync usable :)
only minors: added icon, improved usability
Modified Paths:
--------------
trunk/build/wsync/CMakeLists.txt
trunk/build/wsync/include/wsync.h
trunk/build/wsync/source/main.cpp
trunk/build/wsync/source/wsync.cpp
Added Paths:
-----------
trunk/build/wsync/source/icon.rc
trunk/build/wsync/source/resource.h
trunk/build/wsync/source/update.ico
Modified: trunk/build/wsync/CMakeLists.txt
===================================================================
--- trunk/build/wsync/CMakeLists.txt 2009-04-16 10:43:15 UTC (rev 183)
+++ trunk/build/wsync/CMakeLists.txt 2009-04-19 22:53:13 UTC (rev 184)
@@ -17,7 +17,7 @@
# first compile the lib, then the console tool
add_library(libwsync STATIC source/SHA1.cpp source/wsync.cpp include/wsync.h)
-add_executable(wsync source/main)
+add_executable(wsync source/main source/icon.rc)
target_link_libraries(wsync libwsync)
Modified: trunk/build/wsync/include/wsync.h
===================================================================
--- trunk/build/wsync/include/wsync.h 2009-04-16 10:43:15 UTC (rev 183)
+++ trunk/build/wsync/include/wsync.h 2009-04-19 22:53:13 UTC (rev 184)
@@ -73,5 +73,6 @@
int ensurePathExist(boost::filesystem::path &path);
std::string formatFilesize(boost::uintmax_t size);
void progressOutput(float progress, float speed=-1);
+ void progressOutputShort(float progress);
};
#endif
Added: trunk/build/wsync/source/icon.rc
===================================================================
--- trunk/build/wsync/source/icon.rc (rev 0)
+++ trunk/build/wsync/source/icon.rc 2009-04-19 22:53:13 UTC (rev 184)
@@ -0,0 +1,72 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+//#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+//#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+//#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// French (France) resources
+
+//#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)
+//#ifdef _WIN32
+//LANGUAGE LANG_FRENCH, SUBLANG_FRENCH
+//#pragma code_page(1252)
+//#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_ICON1 ICON DISCARDABLE "update.ico"
+
+//#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+//1 TEXTINCLUDE DISCARDABLE
+//BEGIN
+// "resource.h\0"
+//END
+
+//2 TEXTINCLUDE DISCARDABLE
+//BEGIN
+// "#include ""afxres.h""\r\n"
+// "\0"
+//END
+
+//3 TEXTINCLUDE DISCARDABLE
+//BEGIN
+// "\r\n"
+// "\0"
+//END
+
+//#endif // APSTUDIO_INVOKED
+
+//#endif // French (France) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+//#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+//#endif // not APSTUDIO_INVOKED
+
Modified: trunk/build/wsync/source/main.cpp
===================================================================
--- trunk/build/wsync/source/main.cpp 2009-04-16 10:43:15 UTC (rev 183)
+++ trunk/build/wsync/source/main.cpp 2009-04-19 22:53:13 UTC (rev 184)
@@ -11,6 +11,9 @@
printf(" * creates a new file index for the specified directory\n");
printf(" mode can be 'full' or 'not-delete'\n");
printf("\n");
+ printf("wsync sync\n");
+ printf(" * shortcut with predefined paths for RoR\n");
+ printf("\n");
printf("wsync sync <local path> <remote server> <remote path>\n");
printf(" * syncs the specified directory with the server\n");
}
@@ -39,6 +42,15 @@
string remote_path = string(argv[4]);
WSync *w = new WSync();
w->sync(local_path, remote_server, remote_path);
+ } else if((argc == 2 && !strcmp(argv[1], "sync")) || (argc == 1) )
+ {
+ // shortcut
+ string local_path = ".";
+ string remote_server = "wsync.rigsofrods.com";
+ string remote_path = "/";
+ WSync *w = new WSync();
+ w->sync(local_path, remote_server, remote_path);
+/*
} else if(argc == 2 && !strcmp(argv[1], "test"))
{
std::vector< std::vector< std::string > > list;
@@ -54,8 +66,10 @@
printf("'%s'\n", it2->c_str());
}
}
-
+*/
+ } else
+ {
+ usage();
}
- usage();
return 0;
}
Added: trunk/build/wsync/source/resource.h
===================================================================
--- trunk/build/wsync/source/resource.h (rev 0)
+++ trunk/build/wsync/source/resource.h 2009-04-19 22:53:13 UTC (rev 184)
@@ -0,0 +1,16 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by icon.rc
+//
+#define IDI_ICON1 101
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 102
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1000
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
Added: trunk/build/wsync/source/update.ico
===================================================================
(Binary files differ)
Property changes on: trunk/build/wsync/source/update.ico
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/build/wsync/source/wsync.cpp
===================================================================
--- trunk/build/wsync/source/wsync.cpp 2009-04-16 10:43:15 UTC (rev 183)
+++ trunk/build/wsync/source/wsync.cpp 2009-04-19 22:53:13 UTC (rev 184)
@@ -102,12 +102,29 @@
if(filesToDownload)
printf("downloading %d files now (%s) ..\n", filesToDownload,
formatFilesize(predDownloadSize).c_str());
- // do things now!
+ int changeCounter = 0, changeMax = changedFiles.size() +
newFiles.size() + deletedFiles.size();
+ // do things now!
+ if(newFiles.size())
+ {
+ for(itf=newFiles.begin();itf!=newFiles.end();itf++,
changeCounter++)
+ {
+
progressOutputShort(float(changeCounter)/float(changeMax));
+ printf(" A %s (%s) ", itf->filename.c_str(),
formatFilesize(itf->filesize).c_str());
+ path localfile = localDir / itf->filename;
+ string url = "/" + remoteDir + "/" + itf->filename;
+ if(downloadFile(localfile, server, url, true))
+ printf("\nunable to create file: %s\n",
itf->filename.c_str());
+ else
+ printf(" \n");
+ }
+ }
+
if(changedFiles.size())
{
- for(itf=changedFiles.begin();itf!=changedFiles.end();itf++)
+ for(itf=changedFiles.begin();itf!=changedFiles.end();itf++,
changeCounter++)
{
- printf("U %s (%s) ", itf->filename.c_str(),
formatFilesize(itf->filesize).c_str());
+
progressOutputShort(float(changeCounter)/float(changeMax));
+ printf(" U %s (%s) ", itf->filename.c_str(),
formatFilesize(itf->filesize).c_str());
path localfile = localDir / itf->filename;
string url = "/" + remoteDir + "/" + itf->filename;
if(downloadFile(localfile, server, url, true))
@@ -119,9 +136,10 @@
if(deletedFiles.size() && !(modeNumber & WMO_NODELETE))
{
- for(itf=deletedFiles.begin();itf!=deletedFiles.end();itf++)
+ progressOutputShort(float(changeCounter)/float(changeMax));
+ for(itf=deletedFiles.begin();itf!=deletedFiles.end();itf++,
changeCounter++)
{
- printf("D %s (%s)\n", itf->filename.c_str(),
formatFilesize(itf->filesize).c_str());
+ printf(" D %s (%s)\n", itf->filename.c_str(),
formatFilesize(itf->filesize).c_str());
path localfile = localDir / itf->filename;
try
{
@@ -134,20 +152,6 @@
}
}
}
-
- if(newFiles.size())
- {
- for(itf=newFiles.begin();itf!=newFiles.end();itf++)
- {
- printf("A %s (%s) ", itf->filename.c_str(),
formatFilesize(itf->filesize).c_str());
- path localfile = localDir / itf->filename;
- string url = "/" + remoteDir + "/" + itf->filename;
- if(downloadFile(localfile, server, url, true))
- printf("\nunable to create file: %s\n",
itf->filename.c_str());
- else
- printf(" \n");
- }
- }
printf("sync complete, downloaded %s\n",
formatFilesize(downloadSize).c_str());
@@ -171,8 +175,11 @@
{
vector<string> files;
listFiles(path, files);
- for(vector<string>::iterator it=files.begin(); it!=files.end(); it++)
+ printf("building local file index ...");
+ int counter = 0, counterMax = files.size();
+ for(vector<string>::iterator it=files.begin(); it!=files.end(); it++,
counter++)
{
+ progressOutput(float(counter)/float(counterMax));
// cut out root path
string respath = *it;
if(respath.substr(0, rootpath.string().size()) ==
rootpath.string())
@@ -198,6 +205,7 @@
Hashentry entry(resultHash, file_size(*it));
hashMap[respath] = entry;
}
+ printf("done. \n");
if(writeFile)
return saveHashMapToFile(outfilename, hashMap, mode);
return 0;
@@ -532,6 +540,10 @@
}
}
+void WSync::progressOutputShort(float progress)
+{
+ printf("% 3.0f%%|", progress * 100);
+}
int WSync::getTempFilename(path &tempfile)
{
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today.
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
Rigsofrods-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel