MCPcopy Create free account
hub / github.com/buggins/coolreader / OpenFile

Method OpenFile

crengine/src/lvstream.cpp:924–957  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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;

Callers 3

CreateFileStreamMethod · 0.45
CreateFileStreamMethod · 0.45
CreateFileStreamFunction · 0.45

Calls 2

UnicodeToLocalFunction · 0.85
c_strMethod · 0.45

Tested by

no test coverage detected