| 922 | } |
| 923 | } |
| 924 | lverror_t OpenFile( lString16 fname, lvopen_mode_t mode ) |
| 925 | { |
| 926 | m_mode = mode; |
| 927 | m_file = NULL; |
| 928 | SetName(fname.c_str()); |
| 929 | const char * modestr = "r"; |
| 930 | switch (mode) { |
| 931 | case LVOM_READ: |
| 932 | modestr = "rb"; |
| 933 | break; |
| 934 | case LVOM_WRITE: |
| 935 | modestr = "wb"; |
| 936 | break; |
| 937 | case LVOM_READWRITE: |
| 938 | case LVOM_APPEND: |
| 939 | modestr = "a+b"; |
| 940 | break; |
| 941 | case LVOM_CLOSED: |
| 942 | case LVOM_ERROR: |
| 943 | break; |
| 944 | } |
| 945 | FILE * file = fopen(UnicodeToLocal(fname).c_str(), modestr); |
| 946 | if (!file) |
| 947 | { |
| 948 | //printf("cannot open file %s\n", UnicodeToLocal(fname).c_str()); |
| 949 | m_mode = LVOM_ERROR; |
| 950 | return LVERR_FAIL; |
| 951 | } |
| 952 | m_file = file; |
| 953 | //printf("file %s opened ok\n", UnicodeToLocal(fname).c_str()); |
| 954 | // set filename |
| 955 | SetName( fname.c_str() ); |
| 956 | return LVERR_OK; |
| 957 | } |
| 958 | LVFileStream() : m_file(NULL) |
| 959 | { |
| 960 | m_mode=LVOM_ERROR; |
no test coverage detected