Skip to content

Commit

Permalink
Prevent success trying to open a zip-based file for writing, allow wr…
Browse files Browse the repository at this point in the history
…iting from the stdio wrapper, minor comment fixup
  • Loading branch information
fgenesis committed May 27, 2014
1 parent 43f4fb6 commit 2250278
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
3 changes: 2 additions & 1 deletion examples/example8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
#include <ttvfs.h>
#include <cstdio>

// This example creates a VFS root to obtain a single file.
// This example creates a VFS root to obtain a single file,
// then deletes the root before using the file.
// The file stays valid until the CountedPtr is destroyed.
// You can use CountedPtr::content() to obtain a raw pointer,
// but usually conversions are done automatically.
Expand Down
6 changes: 0 additions & 6 deletions ttvfs_cfileapi/ttvfs_stdio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ void ttvfs_setroot(ttvfs::Root *root)

VFILE *vfopen(const char *fn, const char *mode)
{
if (strchr(mode, 'w'))
{
assert(0 && "ttvfs_stdio: File writing via VFS not yet supported!");
return NULL;
}

VFILE *vf = vfs->GetFile(fn);
if (!vf || !vf->open(mode))
return NULL;
Expand Down
5 changes: 3 additions & 2 deletions ttvfs_cfileapi/ttvfs_stdio.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
// * Define VFS_ENABLE_C_API to 1 to use ttvfs overrides.

/*
This file is a minimal wrapper to replace the C API and std::ifstream.
Note that if you have an advanced needs, this wrapper API is not for you.
This file is a poor man's wrapper to replace the C API and std::ifstream.
Note that if you have any advanced needs, this wrapper API is not for you.
To use it, go through your code and rename all FILE* to VFILE*,
and fopen() and related to vfopen() (so just put a 'v' in front).
Instead of std::ifstream, use InStream. If you use std::fstream for reading ONLY,
also use InStream.
Make sure that a FILE* is not opened twice at any time - this is not supported.
Note that the seek and tell functions do not offer 64 bit offsets in this API.
*/
Expand Down
2 changes: 2 additions & 0 deletions ttvfs_zip/VFSFileZip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ bool ZipFile::open(const char *mode /* = NULL */)
_pos = 0;
if(!mode)
mode = "rb";
else if(strchr(mode, 'w') || strchr(mode, 'a'))
return false; // writing not yet supported
if(_mode != mode)
{
delete [] _buf;
Expand Down

0 comments on commit 2250278

Please sign in to comment.