void initCwd() { char *rr; char nid[MAX_FILE_NAME_SIZE]; rr = getcwd(s_cwd, MAX_FILE_NAME_SIZE); if (rr==NULL) { // try also with getenv, on some linuxes the statically linked // getcwd does not work. rr = getenv("PWD"); if (rr==NULL) { error(ERR_ST, "can't get current working directory"); sprintf(s_cwd, "."); } else { InternalCheck(strlen(rr) < MAX_FILE_NAME_SIZE); strcpy(s_cwd, rr); } } #if defined (__WIN32__) || defined (__OS2__) /*SBD*/ if (strlen(s_cwd)<=2 || s_cwd[1]!=':') { // starting by drive specification #if defined (__OS2__) /*SBD*/ sprintf(nid,"%c:",_getdrive()); #else /*SBD*/ sprintf(nid,"%c:",tolower('c')); #endif /*SBD*/ if (strlen(nid)+strlen(s_cwd) < MAX_FILE_NAME_SIZE-1) { strcpy(nid+strlen(nid),s_cwd); strcpy(s_cwd,nid); } } strcpy(s_cwd, normalizeFileName(s_cwd, "c:\\")); #else /*SBD*/ strcpy(s_cwd, normalizeFileName(s_cwd, "/")); #endif /*SBD*/ }
QString normalizeFileName(const QString &fileName) { if (fileName.isEmpty()) return fileName; return normalizeFileName(QFileInfo(fileName)); }
char *crTmpFileName_st() { static char ttt[MAX_FILE_NAME_SIZE]; char *tmp; static int count =0; #if defined (__WIN32__) || defined (__OS2__) /*SBD*/ // under Windows tmpnam returns file names in \ root. tmp = getenv("TEMP"); if (tmp==NULL) { tmp = tmpnam(NULL); strcpy(ttt,tmp); } else { sprintf(ttt,"%s\\xrefu%d.tmp", tmp, count++); strcpy(ttt, normalizeFileName(ttt, s_cwd)); } #else /*SBD*/ tmp = tmpnam(NULL); strcpy(ttt,tmp); #endif /*SBD*/ //&fprintf(dumpOut,"temp file: %s\n", ttt); if (ttt == NULL) fatalError(ERR_ST, "can't create temporary file", XREF_EXIT_ERR); InternalCheck(strlen(ttt) < MAX_FILE_NAME_SIZE-1); return(ttt); }