Example #1
0
def QueryInfoKey(space, w_hkey):
    """tuple = QueryInfoKey(key) - Returns information about a key.

key is an already open key, or any one of the predefined HKEY_* constants.

The result is a tuple of 3 items:
An integer that identifies the number of sub keys this key has.
An integer that identifies the number of values this key has.
A long integer that identifies when the key was last modified (if available)
 as 100's of nanoseconds since Jan 1, 1600."""
    hkey = hkey_w(w_hkey, space)
    with lltype.scoped_alloc(rwin32.LPDWORD.TO, 1) as nSubKeys:
        with lltype.scoped_alloc(rwin32.LPDWORD.TO, 1) as nValues:
            with lltype.scoped_alloc(rwin32.PFILETIME.TO, 1) as ft:
                null_dword = lltype.nullptr(rwin32.LPDWORD.TO)
                ret = rwinreg.RegQueryInfoKey(
                    hkey, None, null_dword, null_dword,
                    nSubKeys, null_dword, null_dword,
                    nValues, null_dword, null_dword,
                    null_dword, ft)
                if ret != 0:
                    raiseWindowsError(space, ret, 'RegQueryInfoKey')
                l = ((lltype.r_longlong(ft[0].c_dwHighDateTime) << 32) +
                     lltype.r_longlong(ft[0].c_dwLowDateTime))
                return space.newtuple([space.wrap(nSubKeys[0]),
                                       space.wrap(nValues[0]),
                                       space.wrap(l)])
 def time_t_to_FILE_TIME(time, filetime):
     ft = lltype.r_longlong((time + secs_between_epochs) * 10000000)
     filetime.c_dwHighDateTime = lltype.r_uint(ft >> 32)
     filetime.c_dwLowDateTime = lltype.r_uint(ft & ((1 << 32) - 1))
 def make_longlong(high, low):
     return (lltype.r_longlong(high) << 32) + lltype.r_longlong(low)
        m = 0
        if attributes & FILE_ATTRIBUTE_DIRECTORY:
            m |= _S_IFDIR | 0111 # IFEXEC for user,group,other
        else:
            m |= _S_IFREG
        if attributes & FILE_ATTRIBUTE_READONLY:
            m |= 0444
        else:
            m |= 0666
        return m

    def make_longlong(high, low):
        return (lltype.r_longlong(high) << 32) + lltype.r_longlong(low)

    # Seconds between 1.1.1601 and 1.1.1970
    secs_between_epochs = lltype.r_longlong(11644473600)

    def FILE_TIME_to_time_t_nsec(filetime):
        ft = make_longlong(filetime.c_dwHighDateTime, filetime.c_dwLowDateTime)
        # FILETIME is in units of 100 nsec
        nsec = (ft % 10000000) * 100
        time = (ft / 10000000) - secs_between_epochs
        return time, nsec

    def time_t_to_FILE_TIME(time, filetime):
        ft = lltype.r_longlong((time + secs_between_epochs) * 10000000)
        filetime.c_dwHighDateTime = lltype.r_uint(ft >> 32)
        filetime.c_dwLowDateTime = lltype.r_uint(ft & ((1 << 32) - 1))
        
    def attribute_data_to_stat(info):
        st_mode = attributes_to_mode(info.c_dwFileAttributes)
Example #5
0
 def time_t_to_FILE_TIME(time, filetime):
     ft = lltype.r_longlong((time + secs_between_epochs) * 10000000)
     filetime.c_dwHighDateTime = lltype.r_uint(ft >> 32)
     filetime.c_dwLowDateTime = lltype.r_uint(ft & ((1 << 32) - 1))
Example #6
0
 def make_longlong(high, low):
     return (lltype.r_longlong(high) << 32) + lltype.r_longlong(low)
Example #7
0
        m = 0
        if attributes & FILE_ATTRIBUTE_DIRECTORY:
            m |= _S_IFDIR | 0111  # IFEXEC for user,group,other
        else:
            m |= _S_IFREG
        if attributes & FILE_ATTRIBUTE_READONLY:
            m |= 0444
        else:
            m |= 0666
        return m

    def make_longlong(high, low):
        return (lltype.r_longlong(high) << 32) + lltype.r_longlong(low)

    # Seconds between 1.1.1601 and 1.1.1970
    secs_between_epochs = lltype.r_longlong(11644473600)

    def FILE_TIME_to_time_t_nsec(filetime):
        ft = make_longlong(filetime.c_dwHighDateTime, filetime.c_dwLowDateTime)
        # FILETIME is in units of 100 nsec
        nsec = (ft % 10000000) * 100
        time = (ft / 10000000) - secs_between_epochs
        return time, nsec

    def time_t_to_FILE_TIME(time, filetime):
        ft = lltype.r_longlong((time + secs_between_epochs) * 10000000)
        filetime.c_dwHighDateTime = lltype.r_uint(ft >> 32)
        filetime.c_dwLowDateTime = lltype.r_uint(ft & ((1 << 32) - 1))

    def attribute_data_to_stat(info):
        st_mode = attributes_to_mode(info.c_dwFileAttributes)