MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / moveToFileSystem

Method moveToFileSystem

source/io/fszipnode.cpp:32–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30}
31
32bool FsZipNode::moveToFileSystem(std::shared_ptr<FsNode> node) {
33 if (node->isDirectory())
34 return false;
35 if (node->isLink()) {
36 U32 to = ::open((node->nativePath+EXT_LINK).c_str(), O_WRONLY | O_CREAT | O_BINARY, 0666);
37 ::write(to, node->link.c_str(), node->link.length());
38 ::close(to);
39 return true;
40 }
41
42 FsOpenNode* from = this->open(node, K_O_RDONLY);
43 bool result = false;
44 U32 to = ::open(node->nativePath.c_str(), O_WRONLY | O_CREAT | O_BINARY, 0666);
45 if (to != 0xFFFFFFFF) {
46 U8 buffer[4096];
47 U32 read = from->readNative(buffer, 4096);
48 while (read) {
49 if (::write(to, buffer, read) != (int)read)
50 return false;
51 read = from->readNative(buffer, 4096);
52 }
53 ::close(to);
54
55 struct utimbuf settime = { 0, 0 };
56
57 settime.actime = this->zipInfo.lastModified / 1000;
58 settime.modtime = this->zipInfo.lastModified / 1000;
59 utime(node->nativePath.c_str(), &settime);
60
61 result = true;
62 }
63 from->close();
64 return result;
65}
66
67U64 FsZipNode::lastModified() {
68 return this->zipInfo.lastModified;

Callers 1

ensurePathIsLocalMethod · 0.80

Calls 8

openMethod · 0.95
writeFunction · 0.85
isDirectoryMethod · 0.80
closeMethod · 0.65
isLinkMethod · 0.45
c_strMethod · 0.45
lengthMethod · 0.45
readNativeMethod · 0.45

Tested by

no test coverage detected