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

Last change on this file since 124 was 124, checked in by epyon, 12 years ago
  • stream and file_system interfaces added
  • io folder/library added
  • c_stream and c_file_system implementations
File size: 802 bytes
RevLine 
[124]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 );
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.