MCPcopy Create free account
hub / github.com/PDAL/PDAL / openFile

Function openFile

pdal/util/FileUtils.cpp:142–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140
141
142std::istream *openFile(std::string const& filename, bool asBinary)
143{
144 if (filename[0] == '~')
145 throw pdal::pdal_error("PDAL does not support shell expansion");
146
147 VSI::VSIIStream *ifs = nullptr;
148
149 std::string name(filename);
150 if (isStdin(name))
151 name = "/vsistdin/";
152
153 if (!FileUtils::fileExists(name))
154 return nullptr;
155
156 std::ios::openmode mode = std::ios::in;
157 if (asBinary)
158 mode |= std::ios::binary;
159
160 ifs = new Utils::ClassicLocaleStream<VSI::VSIIStream>(name, mode);
161
162 if (!ifs->good())
163 {
164 delete ifs;
165 return nullptr;
166 }
167 return ifs;
168}
169
170
171std::ostream *createFile(std::string const& name, bool asBinary)

Callers 2

readFileIntoStringFunction · 0.70
openFunction · 0.70

Calls 2

isStdinFunction · 0.85
fileExistsFunction · 0.70

Tested by

no test coverage detected