MCPcopy Create free account
hub / github.com/Windscribe/Desktop-App / CreateFile

Function CreateFile

tools/base/utils.py:109–126  ·  view source on GitHub ↗
(filename, force_recreate=False)

Source from the content-addressed store, hash-verified

107
108
109def CreateFile(filename, force_recreate=False):
110 msg.Verbose("CreateFile: \"{}\"".format(filename))
111 ufilename = MakeUnicodePath(filename)
112 if os.path.exists(ufilename):
113 if (force_recreate):
114 RemoveFile(filename)
115 else:
116 msg.Verbose("File already exists")
117 return False
118 for _ in range(_OS_RETRY_COUNT):
119 try:
120 f = open(ufilename, "w")
121 f.close()
122 return True
123 except EnvironmentError as e:
124 last_error = e
125 time.sleep(1)
126 raise IOError("Can't create file \"{}\"!\nLast error: {}".format(filename, last_error))
127
128
129def CreateFileWithContents(filename, text="", force_recreate=False):

Callers 4

CreateFileWithContentsFunction · 0.85
writeMinidumpMethod · 0.85
myCreatePipeExMethod · 0.85

Calls 4

MakeUnicodePathFunction · 0.85
RemoveFileFunction · 0.85
formatMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected