| 74 | #define DIRECT_IO_FLAGS (O_DIRECT | O_SYNC) |
| 75 | |
| 76 | void TDirectIOBufferedFile::SetDirectIO(bool value) { |
| 77 | #ifdef _linux_ |
| 78 | if (DirectIO == value) { |
| 79 | return; |
| 80 | } |
| 81 | |
| 82 | if (!!Alignment && value) { |
| 83 | (void)fcntl(File.GetHandle(), F_SETFL, fcntl(File.GetHandle(), F_GETFL) | DIRECT_IO_FLAGS); |
| 84 | } else { |
| 85 | (void)fcntl(File.GetHandle(), F_SETFL, fcntl(File.GetHandle(), F_GETFL) & ~DIRECT_IO_FLAGS); |
| 86 | } |
| 87 | |
| 88 | DirectIO = value; |
| 89 | #else |
| 90 | DirectIO = value; |
| 91 | #endif |
| 92 | } |
| 93 | |
| 94 | TDirectIOBufferedFile::~TDirectIOBufferedFile() { |
| 95 | try { |