MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / add_file

Method add_file

tools/python-3.11.9-amd64/Lib/msilib/__init__.py:331–378  ·  view source on GitHub ↗

Add a file to the current component of the directory, starting a new one if there is no current component. By default, the file name in the source and the file table will be identical. If the src file is specified, it is interpreted relative to the current directory. Optio

(self, file, src=None, version=None, language=None)

Source from the content-addressed store, hash-verified

329 return file
330
331 def add_file(self, file, src=None, version=None, language=None):
332 """Add a file to the current component of the directory, starting a new one
333 if there is no current component. By default, the file name in the source
334 and the file table will be identical. If the src file is specified, it is
335 interpreted relative to the current directory. Optionally, a version and a
336 language can be specified for the entry in the File table."""
337 if not self.component:
338 self.start_component(self.logical, current_feature, 0)
339 if not src:
340 # Allow relative paths for file if src is not specified
341 src = file
342 file = os.path.basename(file)
343 absolute = os.path.join(self.absolute, src)
344 assert not re.search(r'[\?|><:/*]"', file) # restrictions on long names
345 if file in self.keyfiles:
346 logical = self.keyfiles[file]
347 else:
348 logical = None
349 sequence, logical = self.cab.append(absolute, file, logical)
350 assert logical not in self.ids
351 self.ids.add(logical)
352 short = self.make_short(file)
353 full = "%s|%s" % (short, file)
354 filesize = os.stat(absolute).st_size
355 # constants.msidbFileAttributesVital
356 # Compressed omitted, since it is the database default
357 # could add r/o, system, hidden
358 attributes = 512
359 add_data(self.db, "File",
360 [(logical, self.component, full, filesize, version,
361 language, attributes, sequence)])
362 #if not version:
363 # # Add hash if the file is not versioned
364 # filehash = FileHash(absolute, 0)
365 # add_data(self.db, "MsiFileHash",
366 # [(logical, 0, filehash.IntegerData(1),
367 # filehash.IntegerData(2), filehash.IntegerData(3),
368 # filehash.IntegerData(4))])
369 # Automatically remove .pyc files on uninstall (2)
370 # XXX: adding so many RemoveFile entries makes installer unbelievably
371 # slow. So instead, we have to use wildcard remove entries
372 if file.endswith(".py"):
373 add_data(self.db, "RemoveFile",
374 [(logical+"c", self.component, "%sC|%sc" % (short, file),
375 self.logical, 2),
376 (logical+"o", self.component, "%sO|%so" % (short, file),
377 self.logical, 2)])
378 return logical
379
380 def glob(self, pattern, exclude = None):
381 """Add a list of files to the current component as specified in the

Callers 1

globMethod · 0.95

Calls 10

start_componentMethod · 0.95
make_shortMethod · 0.95
add_dataFunction · 0.85
basenameMethod · 0.80
endswithMethod · 0.80
joinMethod · 0.45
searchMethod · 0.45
appendMethod · 0.45
addMethod · 0.45
statMethod · 0.45

Tested by

no test coverage detected