Skip to content
Snippets Groups Projects
Commit 478e4aa6 authored by Mirar (Pontus Hagland)'s avatar Mirar (Pontus Hagland)
Browse files

added Stdio.File(int fd,...) functionality,

error when failed to open file through create,
default modes when opening file through create ("r" for files, "rw" for fds

Rev: lib/modules/Stdio.pmod/module.pmod:1.63
parent c9a746d8
Branches
Tags
No related merge requests found
// $Id: module.pmod,v 1.62 1999/09/16 20:46:33 noring Exp $ // $Id: module.pmod,v 1.63 1999/09/29 14:57:10 mirar Exp $
import String; import String;
...@@ -138,8 +138,9 @@ class File ...@@ -138,8 +138,9 @@ class File
} }
} }
void create(string|void file,void|string mode,void|int bits) void create(int|string|void file,void|string mode,void|int bits)
{ {
if (zero_type(file)) return;
switch(file) switch(file)
{ {
case "stdin": case "stdin":
...@@ -147,9 +148,6 @@ class File ...@@ -147,9 +148,6 @@ class File
#ifdef __STDIO_DEBUG #ifdef __STDIO_DEBUG
__closed_backtrace=0; __closed_backtrace=0;
#endif #endif
case 0:
break;
case "stdout": case "stdout":
_fd=_stdout; _fd=_stdout;
#ifdef __STDIO_DEBUG #ifdef __STDIO_DEBUG
...@@ -164,13 +162,24 @@ class File ...@@ -164,13 +162,24 @@ class File
#endif #endif
break; break;
case 0..0x7fffffff:
if (!mode) mode="rw";
_fd=Fd(file,mode);
#ifdef __STDIO_DEBUG
__closed_backtrace=0;
#endif
break;
default: default:
_fd=Fd(); _fd=Fd();
#ifdef __STDIO_DEBUG #ifdef __STDIO_DEBUG
__closed_backtrace=0; __closed_backtrace=0;
#endif #endif
if(query_num_arg()<3) bits=0666; if(query_num_arg()<3) bits=0666;
::open(file,mode,bits); if(!mode) mode="r";
if (!::open(file,mode,bits))
error("Failed to open %O mode %O : %s\n",
file,mode,strerror(errno()));
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment