bool System_ShellOpen(char * fileName, va_list args) { bool result = false; char filePath[MAX_F_STRING]; int len; #if defined(__WIN32__) filePath[0] = '"'; vsprintf(filePath+1, fileName, args); #else vsprintf(filePath, fileName, args); #endif len = strlen(filePath); #if defined(__WIN32__) filePath[len] = '"'; filePath[len+1] = '\0'; #else filePath[len] = '\0'; #endif #if !defined(__WIN32__) { strcat(filePath, " &"); if(system(filePath) != -1) result = true; } #elif defined(ECERE_VANILLA) { uint16 * _wfilePath = __ecereNameSpace__ecere__sys__UTF8toUTF16(filePath, null); if(_wsystem(_wfilePath) != -1) result = true; __ecereNameSpace__ecere__com__eSystem_Delete(_wfilePath); } #else { uint16 * _wfilePath = __ecereNameSpace__ecere__sys__UTF8toUTF16(filePath, null); char curDir[MAX_LOCATION]; uint16 * _wcurDir; __ecereNameSpace__ecere__sys__StripLastDirectory(filePath, curDir); _wcurDir = __ecereNameSpace__ecere__sys__UTF8toUTF16(curDir, null); //if(ShellExecute(null, "open", _wfilePath, null, curDir, SW_SHOWNORMAL) > 32) if((void *)ShellExecute(null, null, _wfilePath, null, _wcurDir, SW_SHOWNORMAL) > (void *)32) result = true; __ecereNameSpace__ecere__com__eSystem_Delete(_wfilePath); __ecereNameSpace__ecere__com__eSystem_Delete(_wcurDir); } #endif return result; }
bool System_ShellOpen(char * fileName, va_list args) { bool result = false; char filePath[MAX_F_STRING]; int len; #if defined(__WIN32__) filePath[0] = '"'; vsprintf(filePath+1, fileName, args); #else vsprintf(filePath, fileName, args); #endif len = strlen(filePath); #if defined(__WIN32__) filePath[len] = '"'; filePath[len+1] = '\0'; #else filePath[len] = '\0'; #endif #if !defined(__WIN32__) { char command[MAX_LOCATION] = ""; char desktop[MAX_F_STRING]; __ecereNameSpace__ecere__sys__GetEnvironment("ECERE_DESKTOP", desktop, sizeof(desktop)); if(__ecereNameSpace__ecere__sys__SearchString(desktop, 0, "ecere", false, false)) sprintf(command, "ede-open \"%s\" &", filePath); else { __ecereNameSpace__ecere__sys__GetEnvironment("DESKTOP_SESSION", desktop, sizeof(desktop)); if(__ecereNameSpace__ecere__sys__SearchString(desktop, 0, "gnome", false, false)) sprintf(command, "gnome-open \"%s\" &", filePath); else if(__ecereNameSpace__ecere__sys__SearchString(desktop, 0, "kde", false, false)) sprintf(command, "kde-open \"%s\" &", filePath); else { if(FILE_FileExists(filePath) != isDirectory) sprintf(command, "%s &", filePath); } } if(command[0] && system(command) != -1) result = true; } #elif defined(ECERE_VANILLA) { uint16 * _wfilePath = __ecereNameSpace__ecere__sys__UTF8toUTF16(filePath, null); if(_wsystem(_wfilePath) != -1) result = true; __ecereNameSpace__ecere__com__eSystem_Delete(_wfilePath); } #else { uint16 * _wfilePath = __ecereNameSpace__ecere__sys__UTF8toUTF16(filePath, null); char curDir[MAX_LOCATION]; uint16 * _wcurDir; __ecereNameSpace__ecere__sys__StripLastDirectory(filePath, curDir); _wcurDir = __ecereNameSpace__ecere__sys__UTF8toUTF16(curDir, null); //if(ShellExecute(null, "open", _wfilePath, null, curDir, SW_SHOWNORMAL) > 32) if((void *)ShellExecute(null, null, _wfilePath, null, _wcurDir, SW_SHOWNORMAL) > (void *)32) result = true; __ecereNameSpace__ecere__com__eSystem_Delete(_wfilePath); __ecereNameSpace__ecere__com__eSystem_Delete(_wcurDir); } #endif return result; }