Cached reading of file content (avoiding multiple same file reading) >>> "readCachedFileContent" in readCachedFileContent(__file__) True
(filename, mode="rb")
| 2466 | return retVal |
| 2467 | |
| 2468 | def readCachedFileContent(filename, mode="rb"): |
| 2469 | """ |
| 2470 | Cached reading of file content (avoiding multiple same file reading) |
| 2471 | |
| 2472 | >>> "readCachedFileContent" in readCachedFileContent(__file__) |
| 2473 | True |
| 2474 | """ |
| 2475 | |
| 2476 | if filename not in kb.cache.content: |
| 2477 | with kb.locks.cache: |
| 2478 | if filename not in kb.cache.content: |
| 2479 | checkFile(filename) |
| 2480 | try: |
| 2481 | with openFile(filename, mode) as f: |
| 2482 | kb.cache.content[filename] = f.read() |
| 2483 | except (IOError, OSError, MemoryError) as ex: |
| 2484 | errMsg = "something went wrong while trying " |
| 2485 | errMsg += "to read the content of file '%s' ('%s')" % (filename, getSafeExString(ex)) |
| 2486 | raise SqlmapSystemException(errMsg) |
| 2487 | |
| 2488 | return kb.cache.content[filename] |
| 2489 | |
| 2490 | def average(values): |
| 2491 | """ |
no test coverage detected
searching dependent graphs…