source: cpp/frams/virtfile/stdiofile.cpp @ 224

Last change on this file since 224 was 206, checked in by Maciej Komosinski, 11 years ago

VirtFILE base class provides Vprintf, Vgetc, Vputc, Vrewind, so that subclasses do not have to implement these functions

  • Property svn:eol-style set to native
File size: 1.1 KB
Line 
1// This file is a part of the Framsticks GDK.
2// Copyright (C) 1999-2014  Maciej Komosinski and Szymon Ulatowski.  See LICENSE.txt for details.
3// Refer to http://www.framsticks.com/ for further information.
4
5#include "stdiofile.h"
6#include <common/nonstd_dir.h>
7#include <common/nonstd_stdio.h>
8#include <common/framsg.h>
9
10VirtFILE* StdioFileSystem::Vfopen(const char* path,const char*mode)
11{
12        //printFM("Vfopen %s %s",path,mode);
13#ifdef USE_MFILE
14        MFILE *f=mfopen(path,mode);
15#else
16        FILE *f=fopen(path,mode);
17#endif
18        //printFM("%p",f);
19        if (f) return new StdioFILE(f,path); else return 0;
20}
21
22VirtDIR* StdioFileSystem::Vopendir(const char* path)
23{
24        //printFM("Vopendir %s",path);
25        DIR *d=opendir(path);
26        //printFM("%p",d);
27        if (d) return new StdioDIR(d); else return 0;
28}
29
30int StdioFileSystem::Vfexists(const char* path)
31{
32        return fileExists(path);
33}
34
35void StdioFILE::setStdio()
36{
37        static StdioFILEDontClose si(stdin);
38        static StdioFILEDontClose so(stdout);
39        static StdioFILEDontClose se(stderr);
40        setVstdin(&si);
41        setVstdout(&so);
42        setVstderr(&se);
43}
44
45dirent* StdioDIR::Vreaddir()
46{
47        //printFM("Vreaddir %s",dir);
48        return readdir(dir);
49}
Note: See TracBrowser for help on using the repository browser.