Changeset 22a2bb0 in tol
- Timestamp:
- Mar 20, 2009, 5:00:58 PM (18 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- d9a156c
- Parents:
- 338cca0
- File:
-
- 1 edited
-
tol/bbasic/sys.cpp (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tol/bbasic/sys.cpp
r338cca0 r22a2bb0 45 45 //-------------------------------------------------------------------- 46 46 BTraceInit("sys.cpp"); 47 #ifdef UNIX47 #ifdef UNIX 48 48 BBool BSys::unix_=BTRUE; 49 49 BText BSys::editor_("emacs "); … … 80 80 BSys::MkDir(tolAppData_+"OIS", true); 81 81 BSys::MkDir(tolAppData_+"tests_results",true); 82 tolAppData_ = GetStandardAbsolutePath(tolAppData_); 82 83 } 83 84 return(tolAppData_); … … 226 227 if(!prefix.HasName() || fName.BeginWith(prefix)) 227 228 { 228 path = dir.Name()+"/"+fName;229 // Std(BText("\n") + n + ") " + dir.FileName(n) + msg);230 remove(path.String());229 path = dir.Name()+"/"+fName; 230 // Std(BText("\n") + n + ") " + dir.FileName(n) + msg); 231 remove(path.String()); 231 232 } 232 233 } … … 238 239 //-------------------------------------------------------------------- 239 240 BText BSys::TempNam(const BText& outputDir, 240 const BText& prefix,241 const BText& ext,242 BInt len)241 const BText& prefix, 242 const BText& ext, 243 BInt len) 243 244 244 245 /*! Creates a unique temporal file name in specific directory. … … 260 261 { 261 262 //InitTotalTime("BSys::TempNam"); 262 static BInt fileNumber_ = -1; 263 BText fileName; 264 BText dir = outputDir; 263 static BInt fileNumber_ = -1; 264 BText fileName; 265 BText dir = outputDir; 266 //Std(BText("\nBSys::TempNam 1 dir = ")+dir); 267 if(!dir.HasName()) { dir= TolAppData()+"tmp/"; } 268 //Std(BText("\nBSys::TempNam 2 dir = ")+dir); 269 265 270 //Std("\nBSys::TempNam("); Std(outputDir+", "+prefix+", "+ext+", "+len+")"); 266 if(!(BDir::CheckIsDir(dir)) || (!dir.HasName()) ) 267 { 268 # ifdef UNIX 269 /* tempnam function was deprecated: 270 * dir = GetFilePath(tempnam("","")); */ 271 dir = "/tmp"; 272 # else 273 BText tmp = getenv("TMP"); 274 if(!tmp.HasName()) { tmp = getenv("TEMP"); } 275 dir = tmp; 276 BText dirTOL = dir+"/TOL"; 277 if(!BDir::CheckIsDir(dirTOL)) 278 { 279 system(BText("mkdir \"")+dirTOL+"\""); 280 //MkDir(dirTOL,true); 281 } 282 dir = dirTOL; 283 # endif 284 } 285 BInt attempts = 0; 286 BText pathFile; 287 do 288 { 289 attempts ++; 290 if(len<4) { len=4; } 291 292 BInt base = (BInt)pow(10.0,(double)len); //(BInt)(BDat(10)^BDat(len)).Value(); 293 BInt r = LongRandom(base-1); 294 BText number = BText("")+r; 295 if(len<number.Length()) { number = number.SubString(0,len-1); } 296 fileName = prefix+number+"."+ext; 297 pathFile = dir+"/"+fileName; 271 if(!BDir::CheckIsDir(dir)) 272 { 273 //Std(BText("\nBSys::TempNam 4 dir = ")+dir); 274 mkdir(dir); 275 } 276 //Std(BText("\nBSys::TempNam 5 dir = ")+dir); 277 BInt attempts = 0; 278 BText pathFile; 279 do 280 { 281 attempts ++; 282 if(len<4) { len=4; } 283 BInt base = (BInt)pow(10.0,(double)len); //(BInt)(BDat(10)^BDat(len)).Value(); 284 BInt r = LongRandom(base-1); 285 BText number = BText("")+r; 286 if(len<number.Length()) { number = number.SubString(0,len-1); } 287 fileName = prefix+number+"."+ext; 288 pathFile = dir+fileName; 298 289 // Std(pathFile + " is File " + CheckIsFile(pathFile)); 299 }300 while(CheckIsFile(pathFile));290 } 291 while(CheckIsFile(pathFile)); 301 292 //Std(BText("\nTempNam = ") + fileName + " after " + attempts+ " attempts."); 302 293 //SumPartialTime; 303 return(pathFile);294 return(pathFile); 304 295 } 305 296 … … 316 307 { 317 308 BChar* aux=getenv(envVar.String()); 318 BText tmpName=aux;309 BText tmpName=aux; 319 310 return(tmpName); 320 311 } … … 336 327 { 337 328 Error(BText("\n[")+errno+"]=" + strerror(errno) + "\n" + 338 I2("Cannot execute the command: ",339 "No se pudo ejecutar el mandato: ") + "\n" + command);329 I2("Cannot execute the command: ", 330 "No se pudo ejecutar el mandato: ") + "\n" + command); 340 331 } 341 332 return(!err); … … 415 406 416 407 if (!CreateProcess(NULL, cmd, NULL, NULL, 417 FALSE, 0, NULL, NULL, &startupInfo,418 &piProcInfo))408 FALSE, 0, NULL, NULL, &startupInfo, 409 &piProcInfo)) 419 410 { 420 411 ShowLastError(I2("Creating process \n", … … 529 520 /*! Prints a file in the default printer. Operating systems:<ul> 530 521 * <li>UNIX: print the file with lp command, options:<ul> 531 * <li>-onb: option no banner (don't work).532 * <li>-s: suppress messages from lp such as: request ID is...533 * <li>-c: Make copies of the files to be printed immediately when534 * lp is invoked (and then can be deleted).</ul>522 * <li>-onb: option no banner (don't work). 523 * <li>-s: suppress messages from lp such as: request ID is... 524 * <li>-c: Make copies of the files to be printed immediately when 525 * lp is invoked (and then can be deleted).</ul> 535 526 * <li>WINDOWS: .</ul> 536 527 * \param fileName Name of file to be printed … … 539 530 //-------------------------------------------------------------------- 540 531 { 541 #ifdef UNIX532 #ifdef UNIX 542 533 BText command("lp -c "); 543 534 return(BSys::System(command+fileName)); 544 535 #else // WINDOWS 545 536 ShellExecute( 546 0, // handle to parent window537 0, // handle to parent window 547 538 "print", // string that specifies operation to perform 548 539 fileName.String(), // filename string … … 582 573 //-------------------------------------------------------------------- 583 574 { 584 #ifdef UNIX575 #ifdef UNIX 585 576 BText copyCom("cp "); 586 577 #else // WINDOWS … … 679 670 { 680 671 if(!BSys::Editor().HasName()) { return(BFALSE); } 681 #ifdef UNIX672 #ifdef UNIX 682 673 return(BSys::System(BSys::Editor()+" "+fileName+" &")); 683 674 #else // WINDOWS … … 715 706 { 716 707 if(!BSys::Editor().HasName()) { return(BFALSE); } 717 #ifdef UNIX708 #ifdef UNIX 718 709 return(Edit(fileName,0)); 719 710 #else // WINDOWS … … 740 731 { 741 732 if(!BSys::Editor().HasName()) { return(BFALSE); } 742 #ifdef UNIX733 #ifdef UNIX 743 734 return(Edit(fileName,0)); 744 735 #else // WINDOWS … … 780 771 //-------------------------------------------------------------------- 781 772 { 782 #ifdef UNIX773 #ifdef UNIX 783 774 return(BSys::System(BSys::Editor()+fileName)); 784 775 #else // WINDOWS … … 889 880 ( 890 881 GetCurrentThread(), // handle to the thread 891 &lpExitCode // address to receive termination status882 &lpExitCode // address to receive termination status 892 883 ); 893 884 ExitThread(lpExitCode); … … 901 892 //-------------------------------------------------------------------- 902 893 { 903 #ifndef UNIX894 #ifndef UNIX 904 895 905 896 //Std(BText("\nClient Question : \n")+command+"\n"); 906 897 907 SECURITY_ATTRIBUTES sa =898 SECURITY_ATTRIBUTES sa = 908 899 { 909 900 sizeof(SECURITY_ATTRIBUTES), // structure size 910 0, // No security descriptor901 0, // No security descriptor 911 902 TRUE, // Thread handle is inheritable 912 903 }; 913 904 char* arg = new char[command.Length()+1]; 914 905 strncpy(arg, command.String(), command.Length()+1); 915 DWORD threadId;906 DWORD threadId; 916 907 HANDLE hThread = (HANDLE)CreateThread 917 908 ( 918 909 &sa, // Thread security 919 910 4096, // Thread stack size 920 threadMain, // Thread starting address911 threadMain, // Thread starting address 921 912 (void *)arg, // Thread start argument 922 913 CREATE_SUSPENDED, // Create in suspended state … … 927 918 { 928 919 //MessageBox(0, "Thread Creation Failed", "Error", MB_OK); 929 Error("Thread Creation Failed");920 Error("Thread Creation Failed"); 930 921 return(BFALSE); 931 922 }
Note: See TracChangeset
for help on using the changeset viewer.
