| 46 | } |
| 47 | |
| 48 | static pair<int, int> OpenFlag2NativeFlag(OpenFlag flag) { |
| 49 | int access = 0, create = OPEN_EXISTING; |
| 50 | if ((flag & OpenFlagRWMask) == OpenFlag::ReadWrite) { |
| 51 | access = (GENERIC_READ | GENERIC_WRITE); |
| 52 | } else if (flag & OpenFlag::ReadOnly) { |
| 53 | access |= GENERIC_READ; |
| 54 | } else if (flag & OpenFlag::WriteOnly) { |
| 55 | access |= GENERIC_WRITE; |
| 56 | } |
| 57 | if (flag & OpenFlag::Create) { |
| 58 | create = OPEN_ALWAYS; |
| 59 | } |
| 60 | if (flag & OpenFlag::Excel) { |
| 61 | access = CREATE_NEW; |
| 62 | } |
| 63 | if (flag & OpenFlag::Truncate) { |
| 64 | access = CREATE_ALWAYS; |
| 65 | } |
| 66 | return {access, create}; |
| 67 | } |
| 68 | |
| 69 | bool File::open() { |
| 70 | if (isFileValid()) { |