Python win32api.GetFileAttributes() Examples

The following are 9 code examples of win32api.GetFileAttributes(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module win32api , or try the search function .
Example #1
Source File: browseProjects.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def GetBitmapColumn(self):
		col = 4 # Default
		try:
			if win32api.GetFileAttributes(self.path) & win32con.FILE_ATTRIBUTE_READONLY:
				col = 5
		except win32api.error:
			pass
		return col 
Example #2
Source File: pysynch.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def GetFileAttributes(file, local=1):
    if local: return win32api.GetFileAttributes(file)
    else: return wincerapi.CeGetFileAttributes(file) 
Example #3
Source File: pysynch.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def isdir(name, local=1):
    try:
        attr = GetFileAttributes(name, local)
        return attr & win32con.FILE_ATTRIBUTE_DIRECTORY
    except win32api.error:
        return 0 
Example #4
Source File: nt.py    From deplicate with MIT License 5 votes vote down vote up
def has_archive_attribute(filename):
    try:
        st = lstat(filename)
        flag = bool(st.st_file_attributes & stat.FILE_ATTRIBUTE_ARCHIVE)

    except AttributeError:
        attributes = win32api.GetFileAttributes(filename)
        flag = attributes & win32con.FILE_ATTRIBUTE_ARCHIVE

    return flag 
Example #5
Source File: nt.py    From deplicate with MIT License 5 votes vote down vote up
def has_hidden_attribute(filename):
    try:
        st = lstat(filename)
        flag = bool(st.st_file_attributes & stat.FILE_ATTRIBUTE_HIDDEN)

    except AttributeError:
        attributes = win32api.GetFileAttributes(filename)
        flag = attributes & win32con.FILE_ATTRIBUTE_HIDDEN

    return flag 
Example #6
Source File: nt.py    From deplicate with MIT License 5 votes vote down vote up
def has_system_attribute(filename):
    try:
        st = lstat(filename)
        flag = bool(st.st_file_attributes & stat.FILE_ATTRIBUTE_SYSTEM)

    except AttributeError:
        attributes = win32api.GetFileAttributes(filename)
        flag = attributes & win32con.FILE_ATTRIBUTE_SYSTEM

    return flag 
Example #7
Source File: directory.py    From king-phisher-plugins with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def path_is_hidden(self, path):
		if its.on_windows:
			attribute = win32api.GetFileAttributes(path)
			if attribute & (win32con.FILE_ATTRIBUTE_HIDDEN | win32con.FILE_ATTRIBUTE_SYSTEM):
				return True
		elif self.path_mod.basename(path).startswith('.'):
			return True
		return False 
Example #8
Source File: whipFTP_FileDialogs.py    From whipFTP with MIT License 5 votes vote down vote up
def folder_is_hidden(self, p):
        #See SO question: https://stackoverflow.com/questions/7099290/how-to-ignore-hidden-files-using-os-listdir
        if platform.system() is 'Windows':
            try:
                attribute = win32api.GetFileAttributes(p)
                return attribute & (win32con.FILE_ATTRIBUTE_HIDDEN | win32con.FILE_ATTRIBUTE_SYSTEM)
            except:
                return False
        else:
            return p.startswith('.') 
Example #9
Source File: treedisplays.py    From ExCo with GNU General Public License v3.0 5 votes vote down vote up
def _is_hidden_item(self, item):
        try:
            if data.platform == "Windows":
                # Windows
                attribute = win32api.GetFileAttributes(item)
                hidden = (
                    attribute & 
                    (win32con.FILE_ATTRIBUTE_HIDDEN | 
                        win32con.FILE_ATTRIBUTE_SYSTEM)
                )
            else:
                # Linux / OSX
                hidden = os.path.basename(item).startswith('.')
            return hidden
        except:
            return False