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

Inherits:
Object
  • Object
show all
Includes:
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)



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

def digest
  @digest
end

#flagsInteger

Returns File flags.

Returns:

  • (Integer)

    File flags



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

def flags
  @flags
end

#gidInteger

Returns Group ID.

Returns:

  • (Integer)

    Group ID



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

def gid
  @gid
end

#groupString

Returns Group name.

Returns:

  • (String)

    Group name



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

def group
  @group
end

Returns Symlink target (if symlink).

Returns:

  • (String)

    Symlink target (if symlink)



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

def link_to
  @link_to
end

#modeInteger

Returns File mode.

Returns:

  • (Integer)

    File mode



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

def mode
  @mode
end

#mtimeTime

Returns Modification time.

Returns:

  • (Time)

    Modification time



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

def mtime
  @mtime
end

#pathString

Returns File path.

Returns:

  • (String)

    File path



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

def path
  @path
end

#sizeInteger

Returns File size.

Returns:

  • (Integer)

    File size



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

def size
  @size
end

#uidInteger

Returns User ID.

Returns:

  • (Integer)

    User ID



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

def uid
  @uid
end

#userString

Returns User name.

Returns:

  • (String)

    User name



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

def user
  @user
end

Instance Method Details

#config?Boolean

Check if file is a config file

Returns:

  • (Boolean)


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

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

#directory?Boolean

Check if entry is a directory

Returns:

  • (Boolean)


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

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

#doc?Boolean

Check if file is documentation

Returns:

  • (Boolean)


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

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

#file?Boolean

Check if entry is a regular file

Returns:

  • (Boolean)


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

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

#permissionsString

Get permission string

Returns:

  • (String)

    Unix-style permission string



84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/omnizip/formats/rpm/entry.rb', line 84

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)


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

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