pike.git / lib / master.pike.in

version» Context lines:

pike.git/lib/master.pike.in:1:   /* -*- Pike -*-    * -  * $Id: master.pike.in,v 1.154 2001/05/24 18:14:28 grubba Exp $ +  * $Id: master.pike.in,v 1.155 2001/05/31 22:50:30 hubbe Exp $    *    * Master-file for Pike.    *    * Based on master.pike 1.67.    */      // Some configurable parameters useful for debugging      #pike __REAL_VERSION__   #define PIKE_AUTORELOAD
pike.git/lib/master.pike.in:174:         string master_read_file(string file)   {    object o=_static_modules.files()->Fd();    if(o->open(fakeroot(file),"r"))    return o->read();    return 0;   }    - //! @global - //! Compile the Pike code contained in the file @[filename] into a program. - //! - //! This function will compile the file @[filename] to a Pike program that can - //! later be instantiated. It is the same as doing - //! @code{@[compile_string](@[Stdio.read_file](@[filename]), @[filename])@}. - //! - //! @seealso - //! @[compile()], @[compile_string()], @[cpp()] - //! - program compile_file(string filename, -  object|void handler, -  void|program p, -  void|object o) - { -  AUTORELOAD_CHECK_FILE(filename); -  return compile(cpp(master_read_file(filename), -  filename, -  1, -  handler, -  compat_major, -  compat_minor), -  handler, -  compat_major, -  compat_minor, -  p, -  o); - } -  -  +    #ifdef GETCWD_CACHE   string current_path;   int cd(string s)   {    current_path=0;    return predef::cd(s);   }      string getcwd()   {    return current_path || (current_path=predef::getcwd());   }   #endif      string combine_path_with_cwd(string path)   {    return combine_path(IS_ABSOLUTE_PATH(path)?"/":getcwd(),path);   }    -  + #define Stat _static_modules.files.Stat   #ifdef FILE_STAT_CACHE      #define FILE_STAT_CACHE_TIME 20      int invalidate_time;   mapping(string:multiset(string)) dir_cache = ([]);    - #define Stat _static_modules.files.Stat +    Stat master_file_stat(string x)   {    string file, dir=combine_path_with_cwd(x);       file=BASENAME(dir);    dir=DIRNAME(dir);       multiset(string) d;    if(time() > invalidate_time)    {    dir_cache=([]);    invalidate_time=time()+FILE_STAT_CACHE_TIME;    }    if(zero_type(d=dir_cache[dir]))    {    if(array(string) tmp=get_dir(dir))    { -  + #ifdef __NT__ +  tmp=map(tmp, lower_case); + #endif    d=dir_cache[dir]=aggregate_multiset(@tmp);    }else{    dir_cache[dir]=0;    }    }    -  + #ifdef __NT__ +  file=lower_case(file); + #endif    if(d && !d[file]) return 0;       return predef::file_stat(x);   }   #else   #define master_file_stat file_stat   #endif      mapping (string:string) environment=([]);       -  +    //! @global   //! @decl string getenv(string varname)   //! @decl mapping(string:string) getenv()   //!   //! When called with no arguments, a mapping with all current envrionment   //! variables will be returned.   //!   //! If the @[varname] argument has been given, the value of the environment   //! variable with the name @[varname] will be returned. If no such   //! environment variable exists, @tt{0@} (zero) will be returned.   //!   string|mapping(string:string) getenv(string|void s)   {    if(!s) return environment + ([]);    return environment[s];   }    -  +  + //! @global + //! Compile the Pike code contained in the file @[filename] into a program. + //! + //! This function will compile the file @[filename] to a Pike program that can + //! later be instantiated. It is the same as doing + //! @code{@[compile_string](@[Stdio.read_file](@[filename]), @[filename])@}. + //! + //! @seealso + //! @[compile()], @[compile_string()], @[cpp()] + //! + program compile_file(string filename, +  object|void handler, +  void|program p, +  void|object o) + { +  AUTORELOAD_CHECK_FILE(filename); +  return compile(cpp(master_read_file(filename), +  filename, +  1, +  handler, +  compat_major, +  compat_minor), +  handler, +  compat_major, +  compat_minor, +  p, +  o); + } +  +  +    #if 0   variant mapping(string:string) getenv()   {    return environment + ([]);   }      variant string getenv(string s)   {    return environment[s];   }