我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用win32api.FindFiles()。
def GetServiceClassString(cls, argv = None): if argv is None: argv = sys.argv import pickle modName = pickle.whichmodule(cls, cls.__name__) if modName == '__main__': try: fname = win32api.GetFullPathName(argv[0]) path = os.path.split(fname)[0] # Eaaaahhhh - sometimes this will be a short filename, which causes # problems with 1.5.1 and the silly filename case rule. # Get the long name fname = os.path.join(path, win32api.FindFiles(fname)[0][8]) except win32api.error: raise error("Could not resolve the path name '%s' to a full path" % (argv[0])) modName = os.path.splitext(fname)[0] return modName + "." + cls.__name__
def FindFiles(spec, local=1): if local: return win32api.FindFiles(spec) else: return wincerapi.CeFindFiles(spec)
def BuildFileList(spec, local, recurse, filter, filter_args, recursed_path = ""): files = [] if isdir(spec, local): path = spec raw_spec = "*" else: path, raw_spec = os.path.split(spec) if recurse: # Need full scan, to get sub-direcetories. infos = FindFiles(os.path.join(path, "*"), local) else: infos = FindFiles(os.path.join(path, raw_spec), local) for info in infos: src_name = str(info[8]) full_src_name = os.path.join(path, src_name) if local: # Can't do this for CE! full_src_name = win32api.GetFullPathName(full_src_name) if isdir(full_src_name, local) : if recurse and src_name not in ['.','..']: new_spec = os.path.join(full_src_name, raw_spec) files = files + BuildFileList(new_spec, local, 1, filter, filter_args, os.path.join(recursed_path, src_name)) if fnmatch.fnmatch(src_name, raw_spec): rel_name = os.path.join(recursed_path, src_name) filter_data = filter( full_src_name, rel_name, info, local, filter_args ) if filter_data is not None: files.append( (full_src_name, info, filter_data) ) return files
def OpenDocumentFile(self, filename, bMakeVisible = 1): if filename is not None: try: path = os.path.split(filename)[0] # print "The editor is translating", `filename`,"to", filename = win32api.FindFiles(filename)[0][8] filename = os.path.join(path, filename) # print `filename` except (win32api.error, IndexError), details: pass # print "Couldnt get the full filename!", details return self._obj_.OpenDocumentFile(filename, bMakeVisible)
def OpenDocumentFile(self, filename, bMakeVisible = 1): if filename is not None: try: path = os.path.split(filename)[0] # print "The editor is translating", `filename`,"to", filename = win32api.FindFiles(filename)[0][8] filename = os.path.join(path, filename) # print `filename` except (win32api.error, IndexError) as details: pass # print "Couldnt get the full filename!", details return self._obj_.OpenDocumentFile(filename, bMakeVisible)