Changeset 71 for trunk/orca
- Timestamp:
- 03/03/06 19:14:39 (3 years ago)
- Location:
- trunk/orca
- Files:
-
- 6 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/orca/ChangeLog
r63 r71 4 4 V0.0.24 - ?? March 2006 5 5 6 * 6 * Added make-dir. 7 * Bugfixes. 7 8 8 9 -
trunk/orca/boot.c
r63 r71 301 301 " /wait\n" 302 302 "]\n" 303 "change-dir: native [\n" 304 " value\n" 305 "]\n" 303 "change-dir: native [value]\n" 306 304 "what-dir: native []\n" 305 "make-dir: native [path [file!]]\n" 307 306 "clean-path: native [path [file!]]\n" 308 307 "recycle: native [/off /on]\n" … … 381 380 "orca: true\n" 382 381 "system: context [\n" 383 " version: 0.0.2 4\n"382 " version: 0.0.23\n" 384 383 " os: none\n" 385 384 " error: context [\n" -
trunk/orca/boot.r
r3 r71 410 410 ] 411 411 412 change-dir: native [ 413 value 414 ] 415 412 change-dir: native [value] 416 413 what-dir: native [] 414 make-dir: native [path [file!]] ; url! 417 415 418 416 clean-path: native [path [file!]] ; url! -
trunk/orca/files.c
r42 r71 31 31 extern void orChangeDirNative( OValue* a1 ); 32 32 extern void orWhatDirNative(); 33 extern void orMakeDirNative( OValue* a1 ); 33 34 extern void orRenameNative( OValue* a1 ); 34 35 extern void orDeleteNative( OValue* a1 ); … … 594 595 orNative( orChangeDirNative, "change-dir" ); 595 596 orNative( orWhatDirNative, "what-dir" ); 597 orNative( orMakeDirNative, "make-dir" ); 596 598 orNative( orNowNative, "now" ); 597 599 orNative( orGetenvNative, "getenv" ); -
trunk/orca/unix/os.c
r42 r71 23 23 #include <sys/time.h> 24 24 #include <sys/stat.h> 25 #include <errno.h> 25 26 #include <dirent.h> 26 27 #include <unistd.h> … … 40 41 41 42 43 /** 44 Returns -1 if not present. 45 */ 46 int orFileSize( const char* path ) 47 { 48 struct stat buf; 49 if( stat( path, &buf ) == -1 ) 50 return -1; 51 return buf.st_size; 52 } 53 54 55 /** 56 Returns 1 if directory, 0 if file or -1 if error. 57 */ 58 int orIsDir( const char* path ) 59 { 60 struct stat buf; 61 if( stat( path, &buf ) == -1 ) 62 return -1; 63 return S_ISDIR(buf.st_mode) ? 1 : 0; 64 } 65 66 67 /** 68 Returns 0 if result set to file modification time or -1 if error. 69 */ 70 int orFileModified( const char* path, OValue* res ) 71 { 72 struct stat buf; 73 if( stat( path, &buf ) == -1 ) 74 return -1; 75 76 orSetTF( res, OT_TIME ); 77 res->time.sec = buf.st_mtime; 78 res->time.usec = 0; 79 return 0; 80 } 81 82 42 83 /* 43 84 change-dir … … 46 87 { 47 88 int logic = 0; 48 OString* str = orSTRINGS + a1->index; 89 OString* str = orSTRING(a1); 90 orTermCStr(str); 49 91 if( chdir( str->charArray ) == 0 ) 50 92 logic = 1; … … 69 111 str->used = len; 70 112 memCpy( str->charArray, orTmp, len ); 71 orResultFILE( str - orSTRINGS);113 orResultFILE( orStringN(str) ); 72 114 return; 73 115 } … … 78 120 79 121 /** 80 Returns -1 if not present. 81 */ 82 int orFileSize( const char* path ) 83 { 84 struct stat buf; 85 if( stat( path, &buf ) == -1 ) 86 return -1; 87 return buf.st_size; 88 } 89 90 91 /** 92 Returns 1 if directory, 0 if file or -1 if error. 93 */ 94 int orIsDir( const char* path ) 95 { 96 struct stat buf; 97 if( stat( path, &buf ) == -1 ) 98 return -1; 99 return S_ISDIR(buf.st_mode) ? 1 : 0; 100 } 101 102 103 /** 104 Returns 0 if result set to file modification time or -1 if error. 105 */ 106 int orFileModified( const char* path, OValue* res ) 107 { 108 struct stat buf; 109 if( stat( path, &buf ) == -1 ) 110 return -1; 111 112 orSetTF( res, OT_TIME ); 113 res->time.sec = buf.st_mtime; 114 res->time.usec = 0; 115 return 0; 122 No error if directory exists. 123 */ 124 void orMakeDirNative( OValue* a1 ) 125 { 126 int err; 127 OString* str = orSTRING(a1); 128 orTermCStr(str); 129 err = mkdir( str->charArray, 0755 ); 130 if( err ) 131 { 132 if( (errno != EEXIST) || (orIsDir(str->charArray) != 1) ) 133 { 134 orErrorT( OR_ERROR_ACCESS, strerror/*_r*/(errno) ); 135 } 136 } 116 137 } 117 138 … … 229 250 // What is the overhead of creating the arg list between fork/exec? 230 251 char* argv[10]; 231 argumentList( orSTRING S + a1->index, a1->series.it, argv, 9 );252 argumentList( orSTRING(a1), a1->series.it, argv, 9 ); 232 253 233 254 close( pfd[0] ); … … 306 327 // What is the overhead of creating the arg list between fork/exec? 307 328 char* argv[10]; 308 argumentList( orSTRING S + a1->index, a1->series.it, argv, 9 );329 argumentList( orSTRING(a1), a1->series.it, argv, 9 ); 309 330 310 331 if( execvp( argv[0], argv ) == -1 ) -
trunk/orca/win32/os.c
r42 r71 34 34 seed += clock(); 35 35 return seed; 36 }37 38 39 /*40 change-dir41 */42 void orChangeDirNative( OValue* a1 )43 {44 int logic = 0;45 OString* str = orSTRINGS + a1->index;46 if( _chdir( str->charArray ) == 0 )47 logic = 1;48 orResult( OT_LOGIC, logic );49 }50 51 52 /*53 what-dir54 */55 void orWhatDirNative()56 {57 if( _getcwd( orTmp, OR_TMP_SIZE ) )58 {59 int len;60 OString* str;61 62 len = strLen( orTmp );63 if( len > 0 )64 {65 str = orMakeString( len + OR_CTERM_LEN );66 str->used = len;67 memCpy( str->charArray, orTmp, len );68 orResultFILE( str - orSTRINGS );69 return;70 }71 }72 orResultFALSE;73 36 } 74 37 … … 123 86 return 0; 124 87 */ 88 } 89 90 91 /* 92 change-dir 93 */ 94 void orChangeDirNative( OValue* a1 ) 95 { 96 int logic = 0; 97 OString* str = orSTRING(a1); 98 orTermCStr(str); 99 if( _chdir( str->charArray ) == 0 ) 100 logic = 1; 101 orResult( OT_LOGIC, logic ); 102 } 103 104 105 /* 106 what-dir 107 */ 108 void orWhatDirNative() 109 { 110 if( _getcwd( orTmp, OR_TMP_SIZE ) ) 111 { 112 int len; 113 OString* str; 114 115 len = strLen( orTmp ); 116 if( len > 0 ) 117 { 118 str = orMakeString( len + OR_CTERM_LEN ); 119 str->used = len; 120 memCpy( str->charArray, orTmp, len ); 121 orResultFILE( orStringN(str) ); 122 return; 123 } 124 } 125 orResultFALSE; 126 } 127 128 129 /* 130 No error if directory exists. 131 */ 132 void orMakeDirNative( OValue* a1 ) 133 { 134 int err; 135 OString* str = orSTRING(a1); 136 orTermCStr(str); 137 138 #if 0 139 if( ! CreateDirectory( str->charArray, NULL ) ) 140 { 141 } 142 #else 143 err = _mkdir( str->charArray ); 144 if( err ) 145 { 146 if( (errno != EEXIST) || (orIsDir(str->charArray) != 1) ) 147 { 148 orErrorT( OR_ACCESS_ERR, strerror/*_r*/(errno) ); 149 } 150 } 151 #endif 125 152 } 126 153
