/****************************************************************************** * TMTools.cpp - description * ------------------- * begin : 2005/05/25 * copyright : (C) 2005 by Harald K. Strack * copyright : (C) 2005 by Trymedia Inc. * email : hstrack@trymedia.com ****************************************************************************** * changes name date comment */ /* TMTools: Singleton which holds all functions which are usefull in more than * one hierachy of classes. Like global namespace but nicer. * FIXME: Not yet fully used through the full application. * * */ #include "TMTools.h" //Singleton TMTools * TMTools::_self = NULL; TMTools::TMTools() { } TMTools::~TMTools() { } /* Factory method for singleton. */ TMTools * TMTools::Instance() { if (_self == 0) { _self = new TMTools(); } return _self; } /* Sets an error message to Error * e. * Behaves like printf(). */ void TMTools::SetErrorMsg (Error * e, ErrorSeverity s, const char *fmt, ...) { char buf[1024]; va_list ap; va_start(ap, fmt); vsprintf (buf, fmt, ap); va_end(ap); cerr << buf << endl; e->Set (s,buf); //FIXME: closeme when last revision is closed.. } /* Read Attributes from file */ struct stat * TMTools::GetAttr (char * file, Error * e) { struct stat * attributes = (struct stat *) malloc (sizeof (struct stat)); errno=0; if (lstat (file, attributes) != 0) { int tmp=errno; errno=0; if (e != NULL) { SetErrorMsg (e, E_FATAL,"Fatal: %s: lstat: %s - %s\n", GetDescription ().Text(),file,strerror(tmp)); } else { cerr << "Fatal: " << GetDescription ().Text() << " lstat: " << file << " - " << strerror(tmp) << endl; } return NULL; } return attributes; } /* Do chmod */ void TMTools::SetMode (char * file, mode_t st_mode, Error * e) { errno=0; if ((chmod (file, st_mode)) != 0) { int tmp=errno; errno=0; if (e != NULL) { SetErrorMsg (e, E_FATAL,"Fatal: %s: chmod: %s - %s\n", GetDescription ().Text(), file,strerror(tmp)); } else { cerr << "Fatal: " << GetDescription ().Text() << " chmod: " << file << " - " << strerror(tmp) << endl; } } } /* String for errormessages */ StrBuf & TMTools::GetDescription () { StrBuf * buf = new StrBuf; buf->Set ("TRYMEDIA TOOLS"); return *buf; }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#4 | 5056 | harald_strack |
Directory support. Serious bug concerned to not unzipped binaries removed. Some other small bugfixes. |
||
#3 | 4980 | harald_strack |
Since I am maintaining the stuff in a local repository, I did some copy errors in the last revisions. Fixed. |
||
#2 | 4978 | harald_strack |
ap4 integrate implemented. Octal format is now used to save permissions. NOT backwards compatible anymore!!! |
||
#1 | 4975 | harald_strack |
Permissions are now masked to 555, so no write is possible. If you edit the Makefile and give the parameter -DFULL_PERMS, you have the old behaviour. Bugfix in ap4 revert: Edited and changed files were not reverted correctly. |