feisty meow concerns codebase 2.140
huge_file.h
Go to the documentation of this file.
1#ifndef HUGE_FILE_CLASS
2#define HUGE_FILE_CLASS
3
4/*****************************************************************************\
5* *
6* Name : huge_file *
7* Author : Chris Koeritz *
8* *
9*******************************************************************************
10* Copyright (c) 2007-$now By Author. This program is free software; you can *
11* redistribute it and/or modify it under the terms of the GNU General Public *
12* License as published by the Free Software Foundation; either version 2 of *
13* the License or (at your option) any later version. This is online at: *
14* http://www.fsf.org/copyleft/gpl.html *
15* Please send any updates to: fred@gruntose.com *
16\*****************************************************************************/
17
18#include "byte_filer.h"
19
20#include <basis/astring.h>
21#include <basis/outcome.h>
23#include <basis/enhance_cpp.h>
24
25namespace filesystem {
26
28
36{
37public:
38 huge_file(const basis::astring &filename, const basis::astring &permissions);
40
42 virtual ~huge_file();
43
44 DEFINE_CLASS_NAME("huge_file");
45
46 enum outcomes {
47 OKAY = basis::common::OKAY,
48 FAILURE = basis::common::FAILURE,
49 ACCESS_DENIED = basis::common::ACCESS_DENIED,
50 BAD_INPUT = basis::common::BAD_INPUT
51 };
52
53 const basis::astring &name() const;
55
56 bool good() const;
58
59 bool eof() const;
61
62 double length();
64
65 double file_pointer() const { return _file_pointer; }
67
68 basis::outcome seek(double new_position,
71
75 basis::outcome move_to(double absolute_posn);
77
78 basis::outcome read(basis::byte_array &to_fill, int desired_size, int &size_read);
80
82 basis::outcome write(const basis::byte_array &to_write, int &size_written);
84
86 bool truncate();
88
90 //<! creates the file if it doesn't exist, or updates the time on the file.
91
92 void flush();
94
95private:
96 byte_filer *_real_file;
97 double _file_pointer;
98};
99
100} //namespace.
101
102#endif
103
#define read
Definition Xos2defs.h:38
#define write
Definition Xos2defs.h:46
Provides a dynamically resizable ASCII character string.
Definition astring.h:35
A very common template for a dynamic array of bytes.
Definition byte_array.h:36
Outcomes describe the state of completion for an operation.
Definition outcome.h:31
Provides file managment services using the standard I/O support.
Definition byte_filer.h:32
@ FROM_CURRENT
offset is from current cursor position.
Definition byte_filer.h:96
Provides operations commonly needed on file names.
Definition filename.h:64
Supports reading and writing to very large files, > 4 gigabytes.
Definition huge_file.h:36
double length()
expensive operation accesses the file to find length.
Definition huge_file.cpp:57
bool truncate()
truncates the file after the current position.
Definition huge_file.cpp:55
basis::outcome move_to(double absolute_posn)
simpler seek just goes from current location to "absolute_posn".
bool eof() const
reports when the file pointer has reached the end of the file.
basis::outcome seek(double new_position, byte_filer::origins origin=byte_filer::FROM_CURRENT)
move the file pointer to "new_position" if possible.
double file_pointer() const
returns where we currently are in the file.
Definition huge_file.h:65
basis::outcome touch()
const basis::astring & name() const
returns the name of the file this operates on.
Definition huge_file.cpp:51
bool good() const
reports if the file was opened successfully.
DEFINE_CLASS_NAME("huge_file")
void flush()
forces any pending writes to actually be saved to the file.
Definition huge_file.cpp:53
A platform independent way to obtain the timestamp of a file.