コード例 #1
0
static int posix_open(SgObject self, SgString *path, int flags)
{
  int mode = 0;
  SG_FILE(self)->name = path->value;
  if ((flags & SG_READ) && (flags & SG_WRITE)) {
    mode |= O_RDWR;
  } else {
    if (flags & SG_WRITE) {
      mode |= O_WRONLY;
    }
    if (flags & SG_READ) {
      mode |= O_RDONLY;
    }
  }
  if (flags & SG_CREATE) {
    mode |= O_CREAT;
  }
  if (flags & SG_TRUNCATE) {
    mode |= O_TRUNC;
  }
  SG_FD(self)->fd = open(Sg_Utf32sToUtf8s(path), mode, 0644);
  setLastError(self);
  return SG_FILE_VTABLE(self)->isOpen(self);
}
コード例 #2
0
ファイル: file.c プロジェクト: ktakashi/sagittarius-scheme
static void file_print(SgObject obj, SgPort *port, SgWriteContext *ctx)
{
  Sg_Printf(port, UC("#<file %s>"), SG_FILE(obj)->name);
}