| 36 | | } |
| 37 | | |
| 38 | | |
| 39 | | /* |
| 40 | | change-dir |
| 41 | | */ |
| 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-dir |
| 54 | | */ |
| 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; |
| | 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 |