| 123 | |
| 124 | |
| 125 | Result<int> getContainerStatus( |
| 126 | const string& runtimeDir, |
| 127 | const ContainerID& containerId) |
| 128 | { |
| 129 | const string path = path::join( |
| 130 | getRuntimePath(runtimeDir, containerId), |
| 131 | STATUS_FILE); |
| 132 | |
| 133 | if (!os::exists(path)) { |
| 134 | return None(); |
| 135 | } |
| 136 | |
| 137 | Try<string> read = os::read(path); |
| 138 | if (read.isError()) { |
| 139 | return Error("Unable to read status for container '" + |
| 140 | containerId.value() + "' from checkpoint file '" + |
| 141 | path + "': " + read.error()); |
| 142 | } |
| 143 | |
| 144 | if (read.get() != "") { |
| 145 | Try<int> containerStatus = numify<int>(read.get()); |
| 146 | if (containerStatus.isError()) { |
| 147 | return Error("Unable to read status for container '" + |
| 148 | containerId.value() + "' as integer from '" + |
| 149 | path + "': " + read.error()); |
| 150 | } |
| 151 | |
| 152 | return containerStatus.get(); |
| 153 | } |
| 154 | |
| 155 | return None(); |
| 156 | } |
| 157 | |
| 158 | |
| 159 | #ifndef __WINDOWS__ |