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

Last change on this file since 319 was 319, checked in by epyon, 11 years ago
  • created core module and moved all free source files there
  • took the opportunity to update all copyright lines and minor cleanup
  • minor fixes
  • not all examples are up to date
File size: 816 bytes
Line 
1// Copyright (C) 2012-2014 ChaosForge Ltd
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 && 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.