filename is local here, eg: "strings/german/obj.str" return is either NULL for good else error message to display...
| 843 | // return is either NULL for good else error message to display... |
| 844 | // |
| 845 | static const char *SE_Load_Actual( const char *psFileName, SE_BOOL bLoadDebug, SE_BOOL bSpeculativeLoad ) |
| 846 | { |
| 847 | const char *psErrorMessage = NULL; |
| 848 | |
| 849 | unsigned char *psLoadedData = SE_LoadFileData( psFileName ); |
| 850 | if ( psLoadedData ) |
| 851 | { |
| 852 | // now parse the data... |
| 853 | // |
| 854 | char *psParsePos = (char *) psLoadedData; |
| 855 | |
| 856 | TheStringPackage.SetupNewFileParse( psFileName, bLoadDebug ); |
| 857 | |
| 858 | char sLineBuffer[16384]; // should be enough for one line of text (some of them can be BIG though) |
| 859 | while ( !psErrorMessage && TheStringPackage.ReadLine((const char *&) psParsePos, sLineBuffer ) ) |
| 860 | { |
| 861 | if (strlen(sLineBuffer)) |
| 862 | { |
| 863 | // __DEBUGOUT( sLineBuffer ); |
| 864 | // __DEBUGOUT( "\n" ); |
| 865 | |
| 866 | psErrorMessage = TheStringPackage.ParseLine( sLineBuffer ); |
| 867 | } |
| 868 | } |
| 869 | |
| 870 | SE_FreeFileDataAfterLoad( psLoadedData); |
| 871 | |
| 872 | if (!psErrorMessage && !TheStringPackage.EndMarkerFoundDuringParse()) |
| 873 | { |
| 874 | psErrorMessage = va("Truncated file, failed to find \"%s\" at file end!", sSE_KEYWORD_ENDMARKER); |
| 875 | } |
| 876 | } |
| 877 | else |
| 878 | { |
| 879 | if ( bSpeculativeLoad ) |
| 880 | { |
| 881 | // then it's ok to not find the file, so do nothing... |
| 882 | } |
| 883 | else |
| 884 | { |
| 885 | psErrorMessage = va("Unable to load \"%s\"!", psFileName); |
| 886 | } |
| 887 | } |
| 888 | |
| 889 | return psErrorMessage; |
| 890 | } |
| 891 | |
| 892 | static const char *SE_GetFoundFile( std::string &strResult ) |
| 893 | { |
no test coverage detected