| 30 | } |
| 31 | |
| 32 | bool 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 | |
| 67 | U64 FsZipNode::lastModified() { |
| 68 | return this->zipInfo.lastModified; |
no test coverage detected