3 #if defined(_WIN32) && !defined(__CYGWIN__) 10 #include <sys/types.h> 19 #if defined(_MSC_VER) || defined(__BORLANDC__) 21 #define pclose _pclose 36 if (command==0)
return 1;
40 if (fullCmd.
at(0)!=
'"' && fullCmd.
find(
' ')!=-1)
43 fullCmd=
"\""+fullCmd+
"\"";
51 #if !defined(_WIN32) || defined(__CYGWIN__) 52 (void)commandHasConsole;
56 #ifdef _OS_SOLARIS // for Solaris we use vfork since it is more memory efficient 68 execl(
"/bin/sh",
"sh",
"-c",fullCmd.
data(),(
char*)0);
73 while (waitpid(pid,&status,0 )<0)
84 #else // Other Unices just use fork 97 argv[2] = fullCmd.
data();
99 execve(
"/bin/sh",(
char *
const *)argv,
environ);
104 if (waitpid(pid,&status,0)==-1)
106 if (
errno!=EINTR)
return -1;
110 if (WIFEXITED(status))
112 return WEXITSTATUS(status);
120 #endif // !_OS_SOLARIS 122 #else // Win32 specific 123 if (commandHasConsole)
125 return system(fullCmd);
135 CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
144 SHELLEXECUTEINFOW sInfo = {
145 sizeof(SHELLEXECUTEINFOW),
146 SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI,
152 (LPCWSTR)commandw.
ucs2(),
153 (LPCWSTR)argsw.
ucs2(),
165 if (!ShellExecuteExW(&sInfo))
169 else if (sInfo.hProcess)
171 WaitForSingleObject(sInfo.hProcess,INFINITE);
174 if (!GetExitCodeProcess(sInfo.hProcess,&exitCode))
178 CloseHandle(sInfo.hProcess);
189 #if !defined(_WIN32) || defined(__CYGWIN__) 190 pid = (
uint)getpid();
192 pid = (
uint)GetCurrentProcessId();
197 #if defined(_WIN32) && !defined(__CYGWIN__) 204 if (value==0) value=
"";
205 #if defined(_WIN32) && !defined(__CYGWIN__) 206 SetEnvironmentVariable(name,value);
208 register char **ep = 0;
209 register size_t size;
210 const size_t namelen=
qstrlen(name);
211 const size_t vallen=
qstrlen(value) + 1;
219 (*ep)[namelen] ==
'=')
232 new_environ = (
char **) realloc (
last_environ, (size + 2) *
sizeof (
char *));
236 new_environ = (
char **) malloc ((size + 2) *
sizeof (
char *));
244 new_environ[
size] = (
char *)malloc (namelen + 1 + vallen);
245 if (new_environ[size]==0)
253 memcpy ((
char *) new_environ,
environ, size *
sizeof (
char *));
256 memcpy(new_environ[size], name, namelen);
257 new_environ[
size][namelen] =
'=';
258 memcpy(&new_environ[size][namelen + 1], value, vallen);
259 new_environ[size + 1] = 0;
265 if (len + 1 < namelen + 1 + vallen)
268 char *newString = (
char *)malloc(namelen + 1 + vallen);
275 memcpy(*ep, name, namelen);
276 (*ep)[namelen] =
'=';
277 memcpy(&(*ep)[namelen + 1], value, vallen);
285 #if defined(_WIN32) && !defined(__CYGWIN__) 286 SetEnvironmentVariable(variable,0);
292 if (variable == NULL || *variable ==
'\0' || strchr (variable,
'=') != NULL)
302 if (!
qstrncmp(*ep, variable, (
uint)len) && (*ep)[len]==
'=')
306 do dp[0] = dp[1];
while (*dp++);
324 #if defined(__MINGW32__) 325 return fseeko64(f,offset,whence);
326 #elif defined(_WIN32) && !defined(__CYGWIN__) 327 return _fseeki64(f,offset,whence);
329 return fseeko(f,offset,whence);
335 #if defined(__MINGW32__) 337 #elif defined(_WIN32) && !defined(__CYGWIN__) 346 #if defined(_WIN32) && !defined(__CYGWIN__) 349 return _wfopen((
wchar_t*)fn.
ucs2(),(
wchar_t*)m.
ucs2());
351 return fopen(fileName,mode);
357 #if defined(_WIN32) && !defined(__CYGWIN__) 366 #if defined(_WIN32) && !defined(__CYGWIN__) 375 #if defined(_WIN32) && !defined(__CYGWIN__) 376 return "gswin32c.exe";
384 #if defined(_WIN32) && !defined(__CYGWIN__) 393 #if defined(_WIN32) || defined(macintosh) || defined(__MACOSX__) || defined(__APPLE__) 402 return popen(name,type);
407 return pclose(stream);
427 #if defined(_WIN32) && !defined(__CYGWIN__) 437 if (isalpha (fileName [0]) && fileName[1] ==
':')
440 char const fst = fileName [0];
void portable_sleep(int ms)
Q_EXPORT int qstrncmp(const char *str1, const char *str2, uint len)
bool portable_isAbsolutePath(const char *fileName)
void portable_sysTimerStop()
QCString stripWhiteSpace() const
FILE * portable_popen(const char *name, const char *type)
const char * portable_getenv(const char *variable)
double portable_getSysElapsedTime()
void portable_unsetenv(const char *variable)
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
const char * portable_ghostScriptCommand()
int errno
Contains the last error code.
int find(char c, int index=0, bool cs=TRUE) const
static double g_sysElapsedTime
void portable_sysTimerStart()
static constexpr double ms
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
The QTime class provides clock time functions.
Q_EXPORT uint qstrlen(const char *str)
std::string getenv(std::string const &name)
const unsigned short * ucs2() const
static void print(DebugMask mask, int prio, const char *fmt,...)
portable_off_t portable_fseek(FILE *f, portable_off_t offset, int whence)
const char * data() const
char portable_pathListSeparator()
static char ** last_environ
portable_off_t portable_ftell(FILE *f)
bool portable_fileSystemIsCaseSensitive()
void portable_setenv(const char *name, const char *value)
static QString fromUtf8(const char *, int len=-1)
int portable_pclose(FILE *stream)
const char * portable_commandExtension()
char portable_pathSeparator()
FILE * portable_fopen(const char *fileName, const char *mode)
const char * qPrint(const char *s)
Portable versions of functions that are platform dependent.
int portable_system(const char *command, const char *args, bool commandHasConsole)