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

Last change on this file since 289 was 286, checked in by Maciej Komosinski, 10 years ago

Updated headers

  • Property svn:eol-style set to native
File size: 1.5 KB
RevLine 
[286]1// This file is a part of Framsticks SDK.  http://www.framsticks.com/
2// Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
3// See LICENSE.txt for details.
[109]4
5#include "stdiofile.h"
6#include <common/nonstd_dir.h>
7#include <common/nonstd_stdio.h>
8#include <common/framsg.h>
[281]9#include <common/Convert.h>
[109]10
[281]11VirtFILE* StdioFileSystem::Vfopen(const char *path, const char *mode)
[109]12{
13        //printFM("Vfopen %s %s",path,mode);
[206]14#ifdef USE_MFILE
[281]15        MFILE *f = mfopen(path, mode);
[206]16#else
[281]17#ifdef _WIN32
18        FILE *f = _wfopen(Convert::utf8ToUtf16(path).c_str(), Convert::strTOwstr(mode).c_str());
19#else
20        FILE *f = fopen(path, mode);
[206]21#endif
[281]22#endif
[109]23        //printFM("%p",f);
[281]24        if (f) return new StdioFILE(f, path); else return 0;
[109]25}
26
27VirtDIR* StdioFileSystem::Vopendir(const char* path)
28{
29        //printFM("Vopendir %s",path);
[281]30#ifdef _WIN32
31        DIRTYPE *d = wopendir(Convert::utf8ToUtf16(path).c_str());
32#else
33        DIR *d = opendir(path);
34#endif
[109]35        //printFM("%p",d);
36        if (d) return new StdioDIR(d); else return 0;
37}
38
39int StdioFileSystem::Vfexists(const char* path)
40{
41        return fileExists(path);
42}
43
44void StdioFILE::setStdio()
45{
[227]46#ifndef NO_STD_IN_OUT_ERR
[109]47        static StdioFILEDontClose si(stdin);
48        static StdioFILEDontClose so(stdout);
49        static StdioFILEDontClose se(stderr);
50        setVstdin(&si);
51        setVstdout(&so);
52        setVstderr(&se);
[227]53#endif
[109]54}
55
56dirent* StdioDIR::Vreaddir()
57{
58        //printFM("Vreaddir %s",dir);
[281]59#ifdef _WIN32
60        wdirent *wde=wreaddir(dir);
61        if (wde==NULL) return NULL;
62        strcpy(de.d_name, Convert::wstrToUtf8(wde->d_name).c_str());
63        return &de;
64#else
[109]65        return readdir(dir);
[281]66#endif
[109]67}
Note: See TracBrowser for help on using the repository browser.