| 6821 | |
| 6822 | |
| 6823 | ResultType Line::PerformLoopReadFile(WIN32_FIND_DATA *apCurrentFile, RegItemStruct *apCurrentRegItem |
| 6824 | , char *aCurrentField, bool &aContinueMainLoop, Line *&aJumpToLine, FILE *aReadFile, char *aWriteFileName |
| 6825 | , __int64 &aIndex) |
| 6826 | { |
| 6827 | LoopReadFileStruct loop_info(aReadFile, aWriteFileName); |
| 6828 | size_t line_length; |
| 6829 | ResultType result; |
| 6830 | Line *jump_to_line; |
| 6831 | |
| 6832 | for (; fgets(loop_info.mCurrentLine, sizeof(loop_info.mCurrentLine), loop_info.mReadFile);) |
| 6833 | { |
| 6834 | line_length = strlen(loop_info.mCurrentLine); |
| 6835 | if (line_length && loop_info.mCurrentLine[line_length - 1] == '\n') // Remove newlines like FileReadLine does. |
| 6836 | loop_info.mCurrentLine[--line_length] = '\0'; |
| 6837 | // See comments in PerformLoop() for details about this section. |
| 6838 | result = mNextLine->ExecUntil(ONLY_ONE_LINE, &jump_to_line, apCurrentFile, apCurrentRegItem |
| 6839 | , &loop_info, aCurrentField, ++aIndex); |
| 6840 | if (result == LOOP_BREAK || result == EARLY_RETURN || result == EARLY_EXIT || result == FAIL) |
| 6841 | { |
| 6842 | if (loop_info.mWriteFile) |
| 6843 | fclose(loop_info.mWriteFile); |
| 6844 | return result; |
| 6845 | } |
| 6846 | if (jump_to_line == this) |
| 6847 | { |
| 6848 | aContinueMainLoop = true; |
| 6849 | break; |
| 6850 | } |
| 6851 | if (jump_to_line) |
| 6852 | { |
| 6853 | aJumpToLine = jump_to_line; |
| 6854 | break; |
| 6855 | } |
| 6856 | } |
| 6857 | |
| 6858 | if (loop_info.mWriteFile) |
| 6859 | fclose(loop_info.mWriteFile); |
| 6860 | |
| 6861 | // Don't return result because we want to always return OK unless it was one of the values |
| 6862 | // already explicitly checked and returned above. In other words, there might be values other |
| 6863 | // than OK that aren't explicitly checked for, above. |
| 6864 | return OK; |
| 6865 | } |
| 6866 | |
| 6867 | |
| 6868 | |