Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members
global.cpp
00001 /*********************************************************************** 00002 * * 00003 * ViTooKi * 00004 * * 00005 * title: global.cpp * 00006 * * 00007 * * 00008 * * 00009 * ITEC institute of the University of Klagenfurt (Austria) * 00010 * http://www.itec.uni-klu.ac.at * 00011 * * 00012 * * 00013 * For more information visit the ViTooKi homepage: * 00014 * http://ViTooKi.sourceforge.net * 00015 * vitooki-user@lists.sourceforge.net * 00016 * vitooki-devel@lists.sourceforge.net * 00017 * * 00018 * This file is part of ViTooKi, a free video toolkit. * 00019 * ViTooKi is free software; you can redistribute it and/or * 00020 * modify it under the terms of the GNU General Public License * 00021 * as published by the Free Software Foundation; either version 2 * 00022 * of the License, or (at your option) any later version. * 00023 * * 00024 * This program is distributed in the hope that it will be useful, * 00025 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00026 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00027 * GNU General Public License for more details. * 00028 * * 00029 * You should have received a copy of the GNU General Public License * 00030 * along with this program; if not, write to the Free Software * 00031 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 00032 * MA 02111-1307, USA. * 00033 * * 00034 ***********************************************************************/ 00035 00036 /*********************************************************************** 00037 * * 00038 * REVISION HISTORY: * 00039 * * 00040 * * 00041 * * 00042 ***********************************************************************/ 00043 00044 #include "global.hpp" 00045 00046 bool getTimeString(char *timestr, int len) { 00047 #ifdef WINCE 00048 LPSYSTEMTIME lpst = NULL; 00049 GetLocalTime(lpst); 00050 sprintf(timestr, "%d %s %d %s:%s:%s GMT", lpst->wDay,getMonthName(lpst->wMonth), lpst->wYear, 00051 addLeadingZeros(lpst->wHour), addLeadingZeros(lpst->wMinute), addLeadingZeros(lpst->wSecond)); 00052 #else 00053 time_t tm; 00054 time(&tm); 00055 struct tm lt; 00056 lt = *localtime(&tm); 00057 strftime(timestr, len, "%d %b %Y %H:%M:%S GMT", <); 00058 #endif 00059 00060 if (strlen(timestr) <= (unsigned)len) 00061 return true; 00062 else 00063 return false; 00064 } 00065 00066 00067 unsigned int getFilesize(const char *filename) 00068 { 00069 unsigned int len = 0; 00070 00071 if (strstr(filename, "http://") != NULL) { 00072 len = 0; 00073 dprintf_err("\nglobal func: getFilesize(%s) cannot determine file size for an url!\n",filename); 00074 } else { 00075 FILE *file = fopen(filename, "rb"); 00076 if (file) { 00077 fseek(file, 0, SEEK_END); 00078 len = ftell(file); 00079 fclose(file); 00080 dprintf_full("\nMKContainerFile::getFilesize(%s) = %d\n", filename, len); 00081 } else { 00082 dprintf_err("\nMKContainerFile::getFilesize(%s) cannot open!\n", filename); 00083 } 00084 } 00085 return len; 00086 }