MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / putFile

Method putFile

lib/vfs/machfs.cc:133–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131 }
132
133 void putFile(const Path& path, const Bytes& bytes) override
134 {
135 HfsMount m(this);
136 if (path.size() == 0)
137 throw BadPathException();
138
139 AppleSingle a;
140 try
141 {
142 a.parse(bytes);
143 }
144 catch (const InvalidFileException& e)
145 {
146 throw UnimplementedFilesystemException(
147 "you can only write valid AppleSingle encoded files");
148 }
149
150 auto pathstr = ":" + path.to_str(":");
151 hfs_delete(_vol, pathstr.c_str());
152 HfsFile file(hfs_create(_vol,
153 pathstr.c_str(),
154 (const char*)a.type.cbegin(),
155 (const char*)a.creator.cbegin()));
156 if (!file)
157 throwError();
158
159 hfs_setfork(file, 0);
160 writeBytes(file, a.data);
161 hfs_setfork(file, 1);
162 writeBytes(file, a.rsrc);
163 }
164
165 void deleteFile(const Path& path) override
166 {

Callers

nothing calls this directly

Calls 9

BadPathExceptionClass · 0.85
hfs_deleteFunction · 0.85
hfs_createFunction · 0.85
hfs_setforkFunction · 0.85
to_strMethod · 0.80
cbeginMethod · 0.80
sizeMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected