pike.git / lib / modules / Stdio.pmod / FakeFile.pike

version» Context lines:

pike.git/lib/modules/Stdio.pmod/FakeFile.pike:72:   }      //! Always returns 0.   //! @seealso   //! @[Stdio.File()->errno()]   int errno() { return 0; }      //! Returns size and the creation time of the string.   Stdio.Stat stat() {    Stdio.Stat st = Stdio.Stat(); +  st->isreg = 1;    st->size = sizeof(data);    st->mtime=st->ctime=mtime;    st->atime=time();    return st;   }    -  + int mode() + { +  return 0x1000; // FILE_READ (from Pike/src/modules/_Stdio/file.h) + } +    //! @seealso   //! @[Stdio.File()->line_iterator()]   String.SplitIterator line_iterator(int|void trim) {    if(trim)    return String.SplitIterator( data-"\r", '\n' );    return String.SplitIterator( data, '\n' );   }      protected mixed id;   
pike.git/lib/modules/Stdio.pmod/FakeFile.pike:122:   //! @[Stdio.File()->query_address()]   string query_address(void|int(0..1) is_local) { return 0; }      //! @seealso   //! @[Stdio.File()->read()]   string read(void|int(0..) len, void|int(0..1) not_all) {    if(!r) return 0;    if (len < 0) error("Cannot read negative number of characters.\n");    int start=ptr;    ptr += len; -  if(zero_type(len) || ptr>sizeof(data)) +  if(undefinedp(len) || ptr>sizeof(data))    ptr = sizeof(data);       // FIXME: read callback    return data[start..ptr-1];   }      //! @seealso   //! @[Stdio.FILE()->gets()]   string gets() {    if(!r) return 0;
pike.git/lib/modules/Stdio.pmod/FakeFile.pike:179:    ptr-=sizeof(s);    else    {    data=s+data[ptr..];    ptr=0;    }   }      //! @seealso   //! @[Stdio.File()->seek()] - int seek(int pos, void|int mult, void|int add) { -  if(mult) -  pos = pos*mult+add; -  if(pos<0) + int seek(int pos, string|void how) { +  if( !how )    { -  pos = sizeof(data)+pos; +  how = Stdio.SEEK_SET;    if( pos < 0 ) -  pos = 0; +  how = Stdio.SEEK_END;    } -  +  switch( how ) +  { +  case Stdio.SEEK_SET:    ptr = pos;    if( ptr > strlen( data ) )    ptr = strlen(data); -  +  break; +  case Stdio.SEEK_END: +  ptr = sizeof(data)+pos; +  if( ptr < 0 ) +  ptr = 0; +  break; +  case Stdio.SEEK_CUR: +  ptr += pos; +  if( ptr > strlen( data ) ) +  ptr = strlen(data); +  break; + #if Stdio.SEEK_HOLE +  case Stdio.SEEK_HOLE: +  case Stdio.SEEK_DATA: +  return -1; + #endif +  }    return ptr;   }      //! Always returns 1.   //! @seealso   //! @[Stdio.File()->sync()]   int(1..1) sync() { return 1; }      //! @seealso   //! @[Stdio.File()->tell()]
pike.git/lib/modules/Stdio.pmod/FakeFile.pike:249:    write_oob_cb = 0;   }      //! @seealso   //! @[Stdio.File()->set_blocking_keep_callbacks]   void set_blocking_keep_callbacks() { }      //! @seealso   //! @[Stdio.File()->set_blocking]   void set_nonblocking(function rcb, function wcb, function ccb, -  function rocb, function wocb) { +  void|function rocb, void|function wocb) {    read_cb = rcb;    write_cb = wcb;    close_cb = ccb;    read_oob_cb = rocb;    write_oob_cb = wocb;   }      //! @seealso   //! @[Stdio.File()->set_blocking_keep_callbacks]   void set_nonblocking_keep_callbacks() { }
pike.git/lib/modules/Stdio.pmod/FakeFile.pike:312:      string _sprintf(int t) {    return t=='O' && sprintf("%O(%d,%O)", this_program, sizeof(data),    make_type_str());   }         // FakeFile specials.      //! A FakeFile can be casted to a string. - mixed cast(string to) { -  switch(to) { -  case "string": return data; -  case "object": return this; + protected mixed cast(string to) { +  if( to == "string" ) +  return data; +  return UNDEFINED;   } -  error("Can not cast object to %O.\n", to); - } +       //! Sizeof on a FakeFile returns the size of its contents.   int(0..) _sizeof() {    return sizeof(data);   }      //! @ignore      #define NOPE(X) mixed X (mixed ... args) { error("This is a FakeFile. %s is not available.\n", #X); }   NOPE(assign);
pike.git/lib/modules/Stdio.pmod/FakeFile.pike:341:   NOPE(connect_unix);   NOPE(open);   NOPE(open_socket);   NOPE(pipe);   NOPE(tcgetattr);   NOPE(tcsetattr);      // Stdio.Fd   NOPE(dup2);   NOPE(lock); // We could implement this - NOPE(mode); // We could implement this +    NOPE(proxy); // We could implement this   NOPE(query_fd);   NOPE(read_oob);   NOPE(set_close_on_exec);   NOPE(set_keepalive);   NOPE(trylock); // We could implement this   NOPE(write_oob);      //! @endignore