PetaVision  Alpha
fileio.hpp
1 /*
2  * fileio.hpp
3  *
4  * Created on: Oct 21, 2009
5  * Author: rasmussn
6  */
7 
8 #ifndef FILEIO_HPP_
9 #define FILEIO_HPP_
10 
11 #include "FileStream.hpp"
12 #include "arch/mpi/mpi.h"
13 #include "components/Patch.hpp"
14 #include "include/PVLayerLoc.h"
15 #include "include/pv_types.h"
16 #include "io.hpp"
17 #include "structures/MPIBlock.hpp"
18 #include "utils/BufferUtilsPvp.hpp"
19 
20 #include <sys/stat.h>
21 #include <sys/types.h>
22 #include <unistd.h>
23 #include <vector>
24 
25 namespace PV {
26 
27 // The no-longer-used PatchHeader and PatchListDescription structs were removed Aug 23, 2017.
28 // PatchHeader has the same information as the Patch struct defined in components/Patch.hpp
29 // PatchListDescription was only used internally by readNonsharedWeights and writeNonsharedWeights,
30 // which is now handled by the WeightsFileIO class.
31 
32 // Unused function timeToParams was removed Mar 10, 2017.
33 // Unused function timeFromParams was removed Mar 15, 2017.
34 // Read/write pvp header using ActivityHeader in utils/BufferUtilsPvp, instead
35 // of as an array of ints. ActivityHeader declares timestamp as double.
36 
37 // Unused function pv_sizeof was removed Mar 15, 2017.
38 // Unused function pv_sizeof_patch was removed Mar 15, 2017.
39 // Instead, use BufferUtils::weightPatchSize template in utils/BufferUtilsPvp.
40 
41 PV_Stream *PV_fopen(const char *path, const char *mode, bool verifyWrites);
42 int PV_stat(const char *path, struct stat *buf);
43 long int getPV_StreamFilepos(PV_Stream *pvstream);
44 long int PV_ftell(PV_Stream *pvstream);
45 int PV_fseek(PV_Stream *pvstream, long int offset, int whence);
46 size_t
47 PV_fwrite(const void *RESTRICT ptr, size_t size, size_t nitems, PV_Stream *RESTRICT pvstream);
48 size_t PV_fread(void *RESTRICT ptr, size_t size, size_t nitems, PV_Stream *RESTRICT pvstream);
49 int PV_fclose(PV_Stream *pvstream);
50 void ensureDirExists(MPIBlock const *mpiBlock, char const *dirname);
51 
52 // Unused function pvp_open_read_file was removed Mar 23, 2017. Instead, construct a FileStream.
53 // Unused function pvp_open_write_file was removed Mar 10, 2017. Instead, construct a FileStream.
54 // Unused function pvp_close_file was removed Mar 23, 2017.
55 // Unused functions pvp_read_header and pvp_write_header were removed Mar 15, 2017.
56 // Instead, use the WeightHeader-returning functions in BufferUtils
57 // together with FileStream::read and FileStream::write.
58 
59 // readWeights and writeWeights were separated into Shared and Nonshared versions Mar 15, 2017.
60 // These functions, and functions used only by them were removed Aug 17, 2017.
61 // Use the WeightsFileIO class instead.
62 
63 // calcMinMaxPatch, calcMinMaxNonsharedWeights, calcMinMaxSharedWeights were removed Aug 16, 2017.
64 // Use Weights::calcMinWeights and Weights::calcMaxWeights instead.
65 
66 int pv_text_write_patch(
67  PrintStream *pvstream,
68  Patch const *patch,
69  float *data,
70  int nf,
71  int sx,
72  int sy,
73  int sf);
74 
75 // Unused function pvp_check_file_header was removed Mar 15, 2017.
76 } // namespace PV
77 
78 #endif /* FILEIO_HPP_ */