source: trunk/src/io/c_file_system.cc @ 126

Last change on this file since 126 was 126, checked in by epyon, 12 years ago
  • commiting the gui_element/gui_environment and gui_renderer in it's current state
  • the implementation is very WIP though, but too long stayed out of SVN
  • minor fix to c_file_system
File size: 835 bytes
Line 
1// Copyright (C) 2012-2013 Kornel Kisielewicz
2// This file is part of NV Libraries.
3// For conditions of distribution and use, see copyright notice in nv.hh
4
5#include <cstdio>
6#include "nv/io/c_file_system.hh"
7#include "nv/io/c_stream.hh"
8
9using namespace nv;
10
11c_file_system::c_file_system()
12{
13
14}
15
16c_file_system::~c_file_system()
17{
18
19}
20
21bool c_file_system::exists( const char* fpath )
22{
23        FILE* file = ::fopen( fpath, "rb" );
24        if ( !file )
25        {
26                return false;
27        }
28        ::fclose( file );
29        return true;
30}
31
32stream* c_file_system::open( const char* fpath, const char* fmode /*= "rb" */ )
33{
34        NV_ASSERT( fpath != nullptr && fpath != "" && fmode != nullptr, "Bad parameters passed to open" );
35        FILE* file = ::fopen( fpath, fmode );
36        if ( !file )
37        {
38                return nullptr;
39        }
40        return new c_stream( file, fpath );
41}
Note: See TracBrowser for help on using the repository browser.