00001 #include <highgui.h>
00002 #include <sys/types.h>
00003 #include <sys/stat.h>
00004 #ifdef VAPI_OS_LINUX
00005 #include <unistd.h>
00006 #else
00007 #define _WIN32_WINNT 0x0400
00008 #include <Windows.h>
00009 #endif
00010 #include "vapiTypes.h"
00011 #include "vapiAux.h"
00012 #include "vapiImages.h"
00013 #include "vapi.h"
00014 #ifndef VAPI_WITHOUT_INTERFACE
00015 #include "vapiGtkAux.h"
00016 #include "vapiGtkMessages.h"
00017 #endif
00018
00026 #define NumberMembersToLoad 16
00027
00032 char *
00033 vapiComaToPoint (char *string)
00034 {
00035 int i, size;
00036 size = strlen (string);
00037
00038 for (i = 0; i < size; i++)
00039 {
00040 if (string[i] == ',')
00041 {
00042 string[i] = '.';
00043 }
00044
00045 }
00046 return string;
00047 }
00048
00054 char *
00055 vapiReturnStringPointer (const char *string)
00056 {
00057 char *newString;
00058 newString = malloc ((strlen (string) + 1) * sizeof (char));
00059 strcpy (newString, string);
00060
00061 return newString;
00062
00063 }
00064
00070 void
00071 vapi_loading_progress (const char *Message)
00072 {
00073 double step = (1.0 / NumberMembersToLoad);
00074
00075
00076
00077
00078 vapi_loading_progress_step (Message, step);
00079 }
00080
00091 void
00092 vapi_loading_progress_main_steps (const char *Message, double steps)
00093 {
00094 double step = (1.0 / NumberMembersToLoad) * steps;
00095
00096 vapi_loading_progress_step (Message, step);
00097 }
00098
00099 void
00100 vapi_loading_progress_step (const char *Message, double step)
00101 {
00102 extern double LoadingProgress;
00103 char *OutString;
00104 #ifndef VAPI_WITHOUT_INTERFACE
00105 extern GtkWidget *LoadScreen;
00106 #endif
00107 LoadingProgress += step;
00108 OutString =
00109 v_printf ("%1.2f%% - %s\n", (LoadingProgress * 100), Message);
00110 printf ("%s", OutString);
00111
00112 #ifndef VAPI_WITHOUT_INTERFACE
00113 vapiGtkWriteMessage (OutString, 200);
00114 vapiGtkAuxStepInProgressBar (Message, LoadingProgress);
00115 if (LoadingProgress >= 0.99)
00116 {
00117 gtk_widget_hide (LoadScreen);
00118 }
00119
00120 #endif
00121 if (LoadingProgress >= 0.99)
00122 {
00123 MainLoadDone = vTRUE;
00124 }
00125 free (OutString);
00126 }
00127
00128 vBoolean
00129 vapiFileIsReadable (const char *filename)
00130 {
00131 FILE *fp = fopen (filename, "r");
00132 if (fp)
00133 {
00134 fclose (fp);
00135 return vTRUE;
00136 }
00137 else
00138 {
00139 return vFALSE;
00140 }
00141
00142 }
00143 void
00144 vapi_loading_progress_reset ()
00145 {
00146 extern double LoadingProgress;
00147
00148 #ifndef VAPI_WITHOUT_INTERFACE
00149 gtk_widget_show_all (LoadScreen);
00150 gtk_widget_grab_focus (LoadScreen);
00151 #endif
00152 LoadingProgress = 0.0;
00153 vapi_loading_progress_step (" ", 0.0);
00154 }
00155
00156 vBoolean
00157 vapiIsDirectory (const char *path)
00158 #ifdef VAPI_OS_LINUX
00159 {
00160 struct stat fileinfo;
00161 int ret;
00162
00163 ret = stat (path, &fileinfo);
00164 if ((ret == 0) && S_ISDIR (fileinfo.st_mode))
00165 {
00166 return vTRUE;
00167 }
00168 else
00169 {
00170 return vFALSE;
00171 }
00172 }
00173 #else
00174 {
00175 WIN32_FILE_ATTRIBUTE_DATA FileData;
00176
00177 GetFileAttributesEx (path, GetFileExInfoStandard, &FileData);
00178
00179 if (FileData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY)
00180
00181 {
00182
00183 v_debug ("is directory");
00184
00185 return vTRUE;
00186
00187 }
00188
00189 else
00190
00191 {
00192
00193 v_debug ("is not directory");
00194
00195 return vFALSE;
00196
00197 }
00198 }
00199
00200
00201 #endif