Class: Omnizip::Formats::Rpm::Entry

Inherits:
Object
  • Object
show all
Includes:
Entry, Constants
Defined in:
lib/omnizip/formats/rpm/entry.rb

Overview

RPM file entry

Represents a single file within an RPM package. File information is assembled from multiple header tags.

Constant Summary

Constants included from Constants

Constants::FILE_CONFIG, Constants::FILE_DOC, Constants::FILE_LICENSE, Constants::FILE_README, Constants::FLAG_EQUAL, Constants::FLAG_GREATER, Constants::FLAG_LESS, Constants::HEADER_HEADER_SIZE, Constants::HEADER_MAGIC, Constants::HEADER_SIGNED_TYPE, Constants::LEAD_MAGIC, Constants::LEAD_SIZE, Constants::PACKAGE_BINARY, Constants::PACKAGE_SOURCE, Constants::TAG_ENTRY_SIZE, Constants::TYPE_BINARY, Constants::TYPE_CHAR, Constants::TYPE_I18NSTRING, Constants::TYPE_INT16, Constants::TYPE_INT32, Constants::TYPE_INT64, Constants::TYPE_INT8, Constants::TYPE_NULL, Constants::TYPE_STRING, Constants::TYPE_STRING_ARRAY

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#digestString

Returns File digest (MD5/SHA).

Returns:

  • (String)

    File digest (MD5/SHA)



38
39
40
# File 'lib/omnizip/formats/rpm/entry.rb', line 38

def digest
  @digest
end

#flagsInteger

Returns File flags.

Returns:

  • (Integer)

    File flags



47
48
49
# File 'lib/omnizip/formats/rpm/entry.rb', line 47

def flags
  @flags
end

#gidInteger

Returns Group ID.

Returns:

  • (Integer)

    Group ID



32
33
34
# File 'lib/omnizip/formats/rpm/entry.rb', line 32

def gid
  @gid
end

#groupString

Returns Group name.

Returns:

  • (String)

    Group name



44
45
46
# File 'lib/omnizip/formats/rpm/entry.rb', line 44

def group
  @group
end

Returns Symlink target (if symlink).

Returns:

  • (String)

    Symlink target (if symlink)



50
51
52
# File 'lib/omnizip/formats/rpm/entry.rb', line 50

def link_to
  @link_to
end

#modeInteger

Returns File mode.

Returns:

  • (Integer)

    File mode



26
27
28
# File 'lib/omnizip/formats/rpm/entry.rb', line 26

def mode
  @mode
end

#mtimeTime

Returns Modification time.

Returns:

  • (Time)

    Modification time



35
36
37
# File 'lib/omnizip/formats/rpm/entry.rb', line 35

def mtime
  @mtime
end

#pathString

Returns File path.

Returns:

  • (String)

    File path



20
21
22
# File 'lib/omnizip/formats/rpm/entry.rb', line 20

def path
  @path
end

#sizeInteger

Returns File size.

Returns:

  • (Integer)

    File size



23
24
25
# File 'lib/omnizip/formats/rpm/entry.rb', line 23

def size
  @size
end

#uidInteger

Returns User ID.

Returns:

  • (Integer)

    User ID



29
30
31
# File 'lib/omnizip/formats/rpm/entry.rb', line 29

def uid
  @uid
end

#userString

Returns User name.

Returns:

  • (String)

    User name



41
42
43
# File 'lib/omnizip/formats/rpm/entry.rb', line 41

def user
  @user
end

Instance Method Details

#config?Boolean

Check if file is a config file

Returns:

  • (Boolean)


76
77
78
# File 'lib/omnizip/formats/rpm/entry.rb', line 76

def config?
  @flags.anybits?(FILE_CONFIG)
end

#directory?Boolean

Check if entry is a directory

Returns:

  • (Boolean)


55
56
57
# File 'lib/omnizip/formats/rpm/entry.rb', line 55

def directory?
  (@mode & 0o170_000) == 0o040_000
end

#doc?Boolean

Check if file is documentation

Returns:

  • (Boolean)


83
84
85
# File 'lib/omnizip/formats/rpm/entry.rb', line 83

def doc?
  @flags.anybits?(FILE_DOC)
end

#entry_directory?Boolean

Returns:

  • (Boolean)


15
# File 'lib/omnizip/formats/rpm/entry.rb', line 15

def entry_directory? = mode && ::File.directory?(mode)

#entry_mtimeObject



17
# File 'lib/omnizip/formats/rpm/entry.rb', line 17

def entry_mtime = mtime

#entry_nameObject



14
# File 'lib/omnizip/formats/rpm/entry.rb', line 14

def entry_name = path

#entry_sizeObject



16
# File 'lib/omnizip/formats/rpm/entry.rb', line 16

def entry_size = size

#file?Boolean

Check if entry is a regular file

Returns:

  • (Boolean)


62
63
64
# File 'lib/omnizip/formats/rpm/entry.rb', line 62

def file?
  (@mode & 0o170_000) == 0o100_000
end

#permissionsString

Get permission string

Returns:

  • (String)

    Unix-style permission string



90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/omnizip/formats/rpm/entry.rb', line 90

def permissions
  perms = (@mode & 0o777).to_s(8).rjust(3, "0")

  type_char = if directory?
                "d"
              elsif symlink?
                "l"
              else
                "-"
              end

  "#{type_char}#{perms}"
end

#symlink?Boolean

Check if entry is a symbolic link

Returns:

  • (Boolean)


69
70
71
# File 'lib/omnizip/formats/rpm/entry.rb', line 69

def symlink?
  (@mode & 0o170_000) == 0o120_000
end