source: cpp/common/virtfile/stdiofile.cpp @ 417

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

Renamed logging functions to more intuitive and simple names

  • Property svn:eol-style set to native
File size: 1.4 KB
Line 
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.
4
5#include "stdiofile.h"
6#include <common/nonstd_dir.h>
7#include <common/nonstd_stdio.h>
8#include <common/log.h>
9#include <common/Convert.h>
10
11VirtFILE* StdioFileSystem::Vfopen(const char *path, const char *mode)
12{
13        //log_printf("Vfopen %s %s",path,mode);
14#if defined USE_MFILE || defined _WIN32
15        MFILE *f = mfopen(path, mode);
16#else
17        FILE *f = fopen(path, mode);
18#endif
19        //log_printf("%p",f);
20        if (f) return new StdioFILE(f, path); else return NULL;
21}
22
23VirtDIR* StdioFileSystem::Vopendir(const char* path)
24{
25        //log_printf("Vopendir %s",path);
26#ifdef _WIN32
27        DIRTYPE *d = wopendir(Convert::utf8ToUtf16(path).c_str());
28#else
29        DIR *d = opendir(path);
30#endif
31        //log_printf("%p",d);
32        if (d) return new StdioDIR(d); else return NULL;
33}
34
35bool StdioFileSystem::Vfexists(const char* path)
36{
37        return fileExists(path);
38}
39
40void StdioFILE::setStdio()
41{
42#ifndef NO_STD_IN_OUT_ERR
43        static StdioFILEDontClose si(stdin);
44        static StdioFILEDontClose so(stdout);
45        static StdioFILEDontClose se(stderr);
46        setVstdin(&si);
47        setVstdout(&so);
48        setVstderr(&se);
49#endif
50}
51
52dirent* StdioDIR::Vreaddir()
53{
54        //log_printf("Vreaddir %s",dir);
55#ifdef _WIN32
56        wdirent *wde=wreaddir(dir);
57        if (wde==NULL) return NULL;
58        strcpy(de.d_name, Convert::wstrToUtf8(wde->d_name).c_str());
59        return &de;
60#else
61        return readdir(dir);
62#endif
63}
Note: See TracBrowser for help on using the repository browser.