MCPcopy Index your code
hub / github.com/sqlmapproject/sqlmap / openFile

Function openFile

lib/core/common.py:3802–3828  ·  view source on GitHub ↗

Returns file handle of a given filename >>> "openFile" in openFile(__file__).read() True >>> b"openFile" in openFile(__file__, "rb", None).read() True

(filename, mode='r', encoding=UNICODE_ENCODING, errors="reversible", buffering=1)

Source from the content-addressed store, hash-verified

3800 logger.debug(msg)
3801
3802def openFile(filename, mode='r', encoding=UNICODE_ENCODING, errors="reversible", buffering=1): # "buffering=1" means line buffered (Reference: http://stackoverflow.com/a/3168436)
3803 """
3804 Returns file handle of a given filename
3805
3806 >>> "openFile" in openFile(__file__).read()
3807 True
3808 >>> b"openFile" in openFile(__file__, "rb", None).read()
3809 True
3810 """
3811
3812 # Reference: https://stackoverflow.com/a/37462452
3813 if 'b' in mode:
3814 buffering = 0
3815
3816 if filename == STDIN_PIPE_DASH:
3817 if filename not in kb.cache.content:
3818 kb.cache.content[filename] = sys.stdin.read()
3819
3820 return contextlib.closing(io.StringIO(readCachedFileContent(filename)))
3821 else:
3822 try:
3823 return codecs_open(filename, mode, encoding, errors, buffering)
3824 except IOError:
3825 errMsg = "there has been a file opening error for filename '%s'. " % filename
3826 errMsg += "Please check %s permissions on a file " % ("write" if mode and ('w' in mode or 'a' in mode or '+' in mode) else "read")
3827 errMsg += "and that it's not locked by another process"
3828 raise SqlmapSystemException(errMsg)
3829
3830def decodeIntToUnicode(value):
3831 """

Callers 15

mainFunction · 0.90
storeHashesToFileFunction · 0.90
storeResultsToFileFunction · 0.90
downloadFunction · 0.90
purgeFunction · 0.90
getPageMethod · 0.90
setOutputFileMethod · 0.90
dbTableValuesMethod · 0.90
_listTamperingFunctionsFunction · 0.90
_setPreprocessFunctionsFunction · 0.90
_setPostprocessFunctionsFunction · 0.90
_setTrafficOutputFPFunction · 0.90

Calls 3

readCachedFileContentFunction · 0.85
readMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…