#else // _WIN32
- class FileNameHandle
+ struct FileNameHandle : public std::string
{
- private:
- std::string name;
-
- public:
- FileNameHandle(FileName n) : name(n) {}
- FileName toFileName() const { return name.c_str(); }
+ FileNameHandle(FileName name) : std::string(name) {}
+ operator FileName () const { return c_str(); }
};
typedef FILE* FileHandle;
class FileStream::FileStreamPrivate
{
public:
- FileStreamPrivate(const FileName &fileName) :
- file(InvalidFileHandle),
- name(fileName),
- readOnly(true) {}
+ FileStreamPrivate(const FileName &fileName)
+ : file(InvalidFileHandle)
+ , name(fileName)
+ , readOnly(true)
+ {
+ }
FileHandle file;
FileNameHandle name;
// public members
////////////////////////////////////////////////////////////////////////////////
-FileStream::FileStream(FileName fileName, bool openReadOnly) :
- d(new FileStreamPrivate(fileName))
+FileStream::FileStream(FileName fileName, bool openReadOnly)
+ : d(new FileStreamPrivate(fileName))
{
// First try with read / write mode, if that fails, fall back to read only.
# ifdef _WIN32
debug("Could not open file " + fileName.toString());
# else
- debug("Could not open file " + String(d->name.toFileName()));
+ debug("Could not open file " + String(static_cast<const char *>(d->name)));
# endif
}
}
FileName FileStream::name() const
{
-# ifdef _WIN32
return d->name;
-# else
- return d->name.toFileName();
-# endif
}
ByteVector FileStream::readBlock(ulong length)