static void DaoSTD_Path( DaoProcess *proc, DaoValue *p[], int N ) { DaoVmSpace *vms = proc->vmSpace; DaoNamespace *ns = proc->activeNamespace; dao_boolean full = p[1]->xBoolean.value; switch( p[0]->xEnum.value ){ case 0: DaoProcess_PutString( proc, full ? vms->daoBinFile : vms->daoBinPath ); break; case 1: DaoProcess_PutString( proc, full ? ns->file : ns->name ); break; case 2: DaoProcess_PutString( proc, vms->startPath ); break; case 3: DaoProcess_PutString( proc, ns->path ); break; } }
static void STD_Resource( DaoProcess *proc, DaoValue *p[], int N ) { FILE *fin; DString *file = DString_Copy( p[0]->xString.data ); if( DaoVmSpace_SearchResource( proc->vmSpace, file ) == 0 ){ DaoProcess_RaiseException( proc, DAO_ERROR, "resource file not found" ); DString_Delete( file ); return; } DaoVmSpace_ReadSource( proc->vmSpace, file, file ); DaoProcess_PutString( proc, file ); DString_Delete( file ); }
static void DaoSTD_Resource( DaoProcess *proc, DaoValue *p[], int N ) { FILE *fin; DString *file = DString_Copy( p[0]->xString.value ); if( DaoVmSpace_SearchResource( proc->vmSpace, file, proc->activeNamespace->path ) == 0 ){ DString_InsertChars( file, "resource file not found: ", 0, 0, -1 ); DaoProcess_RaiseError( proc, NULL, file->chars ); DString_Delete( file ); return; } DaoVmSpace_ReadFile( proc->vmSpace, file, file ); DaoProcess_PutString( proc, file ); DString_Delete( file ); }