Changeset 131 for trunk/thune/unix

Show
Ignore:
Timestamp:
05/01/06 16:17:35 (3 years ago)
Author:
krobillard
Message:

Thune - now builds on Windows.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/thune/unix/os.c

    r88 r131  
    2424#include <sys/stat.h> 
    2525#include <dirent.h> 
     26#include <errno.h> 
    2627#include <unistd.h> 
    2728#include <signal.h> 
     
    2930#include "os.h" 
    3031#include "urlan.h" 
     32#include "internal.h" 
    3133 
    3234 
     
    4244/* 
    4345   change-dir 
    44 */ 
    45 void uc_changeDir( UCell* tos ) 
     46   (dir -- logic) 
     47*/ 
     48UR_CALL_PUB( uc_changeDir ) 
    4649{ 
    4750    int logic = 0; 
    48     UString* str = ur_binPtr( tos->series.n ); 
     51    UString* str = ur_bin( tos ); 
     52 
     53    UR_CALL_UNUSED_TH; 
    4954 
    5055    ur_termCStr( str ); 
     
    6166   ( -- path) 
    6267*/ 
    63 void uc_whatDir( UCell* tos ) 
     68UR_CALL_PUB( uc_whatDir ) 
    6469{ 
    6570    char tmp[ 512 ]; 
    6671 
    67     if( getcwd( tmp, 512 ) ) 
     72    UR_S_GROW; 
     73    tos = UR_TOS; 
     74 
     75    if( getcwd( tmp, sizeof(tmp) ) ) 
    6876    { 
    6977        int len; 
     
    127135 
    128136 
    129 #if 0 
    130 #define REF_TIME    a1 
    131  
    132 void uc_now( UCell* a1 ) 
    133 { 
    134     UCell* res; 
     137/* 
     138  (dir-name -- ) 
     139  No error if directory exists. 
     140*/ 
     141UR_CALL_PUB( uc_makeDir ) 
     142{ 
     143    int err; 
     144    UString* str = ur_bin(tos); 
     145    ur_termCStr(str); 
     146    err = mkdir( str->ptr.c, 0755 ); 
     147    if( err ) 
     148    { 
     149        if( (errno != EEXIST) || (ur_isDir(str->ptr.c) != 1) ) 
     150        { 
     151            ur_throwErr( ur_thread, UR_EX_ACCESS, strerror/*_r*/(errno) ); 
     152            return; 
     153        } 
     154    } 
     155    UR_S_DROP; 
     156} 
     157 
     158 
     159// ( -- time) 
     160UR_CALL_PUB( uc_now ) 
     161{ 
    135162    struct timeval tp; 
    136163 
     164    UR_S_GROW; 
     165    tos = UR_TOS; 
     166 
    137167    gettimeofday( &tp, 0 ); 
    138  
    139     //printf( "sizeof(timeval.tv_sec) %d %d\n", 
    140     //        sizeof(tp.tv_sec), sizeof(tp.tv_usec) ); 
    141  
    142     res = orRESULT; 
    143     if( orRefineSet( REF_TIME ) ) 
    144         orSetTF( res, OT_TIME ); 
    145     else 
    146         orSetTF( res, OT_DATE ); 
    147  
    148     res->time.sec  = tp.tv_sec; 
    149     res->time.usec = tp.tv_usec; 
    150 } 
    151 #endif 
     168    ur_seconds(tos) = ((double) tp.tv_sec) + ((double) tp.tv_usec) * 0.000001; 
     169 
     170    ur_setType( tos, UT_TIME ); 
     171} 
    152172 
    153173