 |
|
 |
... in function
bool __fastcall AddThisFileToZip(const CString &filename)
you check each filename for existance of one of the specified (hard-coded) file extensions. Unfortunatelly you do not check the position of the found characters what results in skipping files, which names contain "forbidden" extensions.
There are couple of possible solutions which i can think of:
a. check the position of the found "forbidden" characters/extension to match exactly last 4 letters of the filename (in case when all unwanted extensions are 3 chars long)
szExt = aszExt[i];
// find last dot
nDotPos = filename.ReverseFind('.');
if(nDotPos >= 0)
{
nPos = filename.Find(szExt);
// if first letter of the "forbidden" extension matches exactly first
// letter of the file extentsion AND extensions are of equal length
if((nPos == nDotPos+1) && (strlen(szExt) == (filename.GetLength() - nDotPos - 1)))
return false;
}
b. add . - dot before each extension - who has files that have dots in the middle of them ? So this:
static char* aszExt[] = {
"pch", "idb", "obj", "sbr", "ilk", "pdb",
"iqb", "exp", "trg", "plg", "zip",
"rar", "exe", "ncb",
NULL};
would become this:
static char* aszExt[] = {
".pch", ".idb", ".obj", ".sbr", ".ilk", ".pdb",
".iqb", ".exp", ".trg", ".plg", ".zip",
".rar", ".exe", ".ncb",
NULL};
Choose which you like more
Next thing is that by default the tool deletes all files that have "res" extensions and that includes "res" directory. Anyone had the same problem ?
Thx for the great tool.
Merry Christmas!
Rafal
Good programmer hangs himself together with his program.
|
|
|
|
 |
|
 |
Good point. Literally
---
http://sprdsoft.cmar-net.org - We Sprd You Softly
Our site features contents and several images. All of this is very weird.
http://sprd.12.forumer.com
Our forum features..err..nothing. You're welcome to contribute.
In the end, war is not about who's right, it's about who's left.
|
|
|
|
 |
|
 |
bool __fastcall AddThisFileToZip(const CString &filename) { ///skip the files and will not delete them int filenamelenStartFind = filename.GetLength() - 4; if( ((filename.Find("obj"), filenamelenStartFind ) != (-1)) || ((filename.Find("sbr"), filenamelenStartFind ) != (-1)) || ((filename.Find("ilk"), filenamelenStartFind ) != (-1)) || ((filename.Find("pdb"), filenamelenStartFind ) != (-1)) || ((filename.Find("iqb"), filenamelenStartFind ) != (-1)) || ((filename.Find("exp"), filenamelenStartFind ) != (-1)) || ((filename.Find("res"), filenamelenStartFind ) != (-1)) || ((filename.Find("trg"), filenamelenStartFind ) != (-1)) || ((filename.Find("plg"), filenamelenStartFind ) != (-1)) || ((filename.Find("zip"), filenamelenStartFind ) != (-1)) || ((filename.Find("rar"), filenamelenStartFind ) != (-1)) || ((filename.Find("exe"), filenamelenStartFind ) != (-1)) || ((filename.Find("ncb"), filenamelenStartFind ) != (-1)) ) { return false; } return true; }
In main function comment cleanvc function // Clean directories //cleanVC(currentDir); //put this condition before adding file to zip if(AddThisFileToZip(filename)) { //add only source files and skip other files cout << "Adding: " << (LPCTSTR)filename << endl; // Add file to Zip zip.AddNewFile(filename, level); } I have large projects that some times takes about half and hour to build. This will skip the cleaning process and also skip adding zip and rar files Hope you will not mind this change to source code
|
|
|
|
 |
|
|
 |
|
 |
bool __fastcall AddThisFileToZip(const CString &filename)
{
///skip the files and will not delete them
int nStart = filename.GetLength() - 4;
int i, nPos = 0;
char *szExt;
static char* aszExt[] =
"pch", "idb", "obj", "sbr", "ilk", "pdb",
"iqb", "exp", "res", "trg", "plg", "zip",
"rar", "exe", "ncb",
NULL};
for (i=0; aszExt[i]; i++) {
szExt = aszExt[i];
nPos=filename.Find(szExt);
if (nPos >= 0)
return 0;
}
return true;
}
|
|
|
|
 |
|
 |
bool __fastcall AddThisFileToZip(const CString &filename) { ///skip the files and will not delete them int filenamelenStartFind = filename.GetLength() - 4; if( ((filename.Find("obj"), filenamelenStartFind ) != (-1)) || ((filename.Find("sbr"), filenamelenStartFind ) != (-1)) || ((filename.Find("ilk"), filenamelenStartFind ) != (-1)) || ((filename.Find("pdb"), filenamelenStartFind ) != (-1)) || ((filename.Find("iqb"), filenamelenStartFind ) != (-1)) || ((filename.Find("exp"), filenamelenStartFind ) != (-1)) || ((filename.Find("res"), filenamelenStartFind ) != (-1)) || ((filename.Find("trg"), filenamelenStartFind ) != (-1)) || ((filename.Find("plg"), filenamelenStartFind ) != (-1)) || ((filename.Find("zip"), filenamelenStartFind ) != (-1)) || ((filename.Find("rar"), filenamelenStartFind ) != (-1)) || ((filename.Find("exe"), filenamelenStartFind ) != (-1)) || ((filename.Find("ncb"), filenamelenStartFind ) != (-1)) ) { return false; } return true; }
In main function comment cleanvc function // Clean directories //cleanVC(currentDir); //put this condition before adding file to zip if(AddThisFileToZip(filename)) { //add only source files and skip other files cout << "Adding: " << (LPCTSTR)filename << endl; // Add file to Zip zip.AddNewFile(filename, level); } I have large projects that some times takes about half and hour to build. This will skip the cleaning process and also skip adding zip and rar files Hope you will not mind this change to source code Best backup no cleaning
|
|
|
|
 |
|
 |
Why don't you use something like this to append time to backup file name ?
CTime curTime = CTime::GetCurrentTime();
CString const sFormat = "%Y%m%d_%H%M%S";
CString filename;
filename.Format("%s\\%s_%s.zip", archivePath, folderName, sFormat);
so you would have an immediate time view as MyFTPServer_20030513_154412.zip .
|
|
|
|
 |
|
 |
Mav Rossi wrote:
CTime curTime = CTime::GetCurrentTime();
CString const sFormat = "%Y%m%d_%H%M%S";
CString filename;
filename.Format("%s\\%s_%s.zip", archivePath, folderName, sFormat);
Very good idea ! I will use this format next time I update the code.
|
|
|
|
 |
|
 |
Where does 'curTime' fit in?
Thanks.
William
Fortes in fide et opere!
|
|
|
|
 |
|
 |
Sorry I made a mistake
CTime curTime = CTime::GetCurrentTime();
CString const sFormat = "%Y%m%d_%H%M%S";
CString sTime;
sTime = curTime.Format(sFormat);
CString filename;
filename.Format("%s\\%s_%s.zip", archivePath, folderName, sTime);
|
|
|
|
 |
|
 |
I do this manually all the time! I'll try it out tomorrow.
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
 |
|
 |
I agree, this is very cool!
Another utility that supposts zip and backup is Second Copy http://www.centered.com/[^]. It's highly configurable and seems to work fine. Btw: this is a commercial program that is not open source.
|
|
|
|
 |
|