Call fsync() a list of file names The filenames should be absolute paths already.
(filenames)
| 156 | |
| 157 | |
| 158 | def _fsync_files(filenames): |
| 159 | """Call fsync() a list of file names |
| 160 | |
| 161 | The filenames should be absolute paths already. |
| 162 | |
| 163 | """ |
| 164 | touched_directories = set() |
| 165 | |
| 166 | mode = os.O_RDONLY |
| 167 | |
| 168 | # Windows |
| 169 | if hasattr(os, 'O_BINARY'): |
| 170 | mode |= os.O_BINARY |
| 171 | |
| 172 | for filename in filenames: |
| 173 | fd = os.open(filename, mode) |
| 174 | os.fsync(fd) |
| 175 | os.close(fd) |
| 176 | touched_directories.add(os.path.dirname(filename)) |
| 177 | |
| 178 | # Some OSes also require us to fsync the directory where we've |
| 179 | # created files or subdirectories. |
| 180 | if hasattr(os, 'O_DIRECTORY'): |
| 181 | for dirname in touched_directories: |
| 182 | fd = os.open(dirname, os.O_RDONLY | os.O_DIRECTORY) |
| 183 | os.fsync(fd) |
| 184 | os.close(fd) |
| 185 | |
| 186 | |
| 187 | def cat_extract(tar, member, targetpath): |
no test coverage detected