Class: RPM::File

Inherits:
Object
  • Object
show all
Defined in:
ext/rpm/file.c

Instance Method Summary collapse

Constructor Details

#initialize(path, md5sum, link_to, size, mtime, owner, group, rdev, mode, attr, state) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'ext/rpm/file.c', line 25

static VALUE
file_initialize(VALUE file, VALUE path, VALUE md5sum, VALUE link_to,
				VALUE size, VALUE mtime, VALUE owner, VALUE group,
				VALUE rdev, VALUE mode, VALUE attr, VALUE state)
{
	if (TYPE(path) != T_STRING
		|| TYPE(md5sum) != T_STRING
		|| (!NIL_P(link_to) && TYPE(link_to) != T_STRING)
		|| (!NIL_P(owner) && TYPE(owner) != T_STRING)
		|| (!NIL_P(group) && TYPE(group) != T_STRING)) {
		rb_raise(rb_eTypeError, "illegal argument type");
	}
	rb_ivar_set(file, id_path, path);
	rb_ivar_set(file, id_md5sum, md5sum);
	rb_ivar_set(file, id_link_to, (!NIL_P(link_to) && RSTRING_LEN(link_to)) ? link_to : Qnil);
	rb_ivar_set(file, id_size, rb_Integer(size));
	if (rb_obj_is_kind_of(mtime, rb_cTime) == Qfalse) {
		mtime = rb_time_new(NUM2INT(rb_Integer(mtime)), (time_t)0);
	}
	rb_ivar_set(file, id_mtime, mtime);
	rb_ivar_set(file, id_owner, owner);
	rb_ivar_set(file, id_group, group);
	rb_ivar_set(file, id_rdev, rb_Integer(rdev));
	rb_ivar_set(file, id_mode, UINT2NUM(NUM2UINT(rb_Integer(mode))&0777));
	rb_ivar_set(file, id_attr, rb_Integer(attr));
	rb_ivar_set(file, id_state, rb_Integer(state));

	return file;
}

Instance Method Details

#attrObject



165
166
167
168
169
# File 'ext/rpm/file.c', line 165

VALUE
rpm_file_get_attr(VALUE file)
{
	return rb_ivar_get(file, id_attr);
}

#config?Boolean

Returns True if the file is marked as a configuration file.

Returns:

  • (Boolean)

    True if the file is marked as a configuration file



189
190
191
192
193
# File 'ext/rpm/file.c', line 189

VALUE
rpm_file_is_config(VALUE file)
{
	return (NUM2INT(rb_ivar_get(file, id_attr)) & RPMFILE_CONFIG) ? Qtrue : Qfalse;
}

#doc?Boolean

Returns True if the file is marked as documentation.

Returns:

  • (Boolean)

    True if the file is marked as documentation



198
199
200
201
202
# File 'ext/rpm/file.c', line 198

VALUE
rpm_file_is_doc(VALUE file)
{
	return (NUM2INT(rb_ivar_get(file, id_attr)) & RPMFILE_DOC) ? Qtrue : Qfalse;
}

#donotuse?Boolean

Returns True if the file is marked as do not use.

Returns:

  • (Boolean)

    True if the file is marked as do not use



207
208
209
210
211
212
213
214
215
# File 'ext/rpm/file.c', line 207

VALUE
rpm_file_is_donotuse(VALUE file)
{
#if RPM_VERSION_CODE < RPM_VERSION(4,1,0)
	return (NUM2INT(rb_ivar_get(file, id_attr)) & RPMFILE_DONOTUSE) ? Qtrue : Qfalse;
#else
	return Qfalse;
#endif
}

#exclude?Boolean

Returns True if the file is listed in the exlude section.

Returns:

  • (Boolean)

    True if the file is listed in the exlude section



288
289
290
291
292
# File 'ext/rpm/file.c', line 288

VALUE
rpm_file_is_exclude(VALUE file)
{
	return (NUM2INT(rb_ivar_get(file, id_attr)) & RPMFILE_EXCLUDE) ? Qtrue : Qfalse;
}

#ghost?Boolean

This flag indicates the file should not be included in the package. It can be used to name the needed attributes for a file that the program, when installed,

will create.

For example, you may want to ensure that a program’s log file has certain attributes.

Returns:

  • (Boolean)

    True if the file is marked as ghost



261
262
263
264
265
# File 'ext/rpm/file.c', line 261

VALUE
rpm_file_is_ghost(VALUE file)
{
	return (NUM2INT(rb_ivar_get(file, id_attr)) & RPMFILE_GHOST) ? Qtrue : Qfalse;
}

#groupString

Returns Group that owns the file. Nil may be returned.

Returns:

  • (String)

    Group that owns the file. Nil may be returned.



141
142
143
144
145
# File 'ext/rpm/file.c', line 141

VALUE
rpm_file_get_group(VALUE file)
{
	return rb_ivar_get(file, id_group);
}

#license?Boolean

Returns True if the file is a license.

Returns:

  • (Boolean)

    True if the file is a license



270
271
272
273
274
# File 'ext/rpm/file.c', line 270

VALUE
rpm_file_is_license(VALUE file)
{
	return (NUM2INT(rb_ivar_get(file, id_attr)) & RPMFILE_LICENSE) ? Qtrue : Qfalse;
}
Note:

This path is sometimes relative. To convert an absolute path from relative path: File.expand_path (file.link_to, File.dirname (file.path))

Returns Path to the destination if the file is a symbolic link.

Returns:

  • (String)

    Path to the destination if the file is a symbolic link



105
106
107
108
109
# File 'ext/rpm/file.c', line 105

VALUE
rpm_file_get_link_to(VALUE file)
{
	return rb_ivar_get(file, id_link_to);
}

#md5sumString

Returns md5sum as string.

Returns:

  • (String)

    md5sum as string



93
94
95
96
97
# File 'ext/rpm/file.c', line 93

VALUE
rpm_file_get_md5sum(VALUE file)
{
	return rb_ivar_get(file, id_md5sum);
}

#missingok?Boolean

This modifier is used for files or links that are created during the %post scripts

but will need to be removed if the package is removed

Returns:

  • (Boolean)

    True if the file is marked that can be missing on disk



223
224
225
226
227
# File 'ext/rpm/file.c', line 223

VALUE
rpm_file_is_missingok(VALUE file)
{
	return (NUM2INT(rb_ivar_get(file, id_attr)) & RPMFILE_MISSINGOK) ? Qtrue : Qfalse;
}

#modeNumber

Returns File permissions.

Returns:

  • (Number)

    File permissions



159
160
161
162
163
# File 'ext/rpm/file.c', line 159

VALUE
rpm_file_get_mode(VALUE file)
{
	return rb_ivar_get(file, id_mode);
}

#mtimeTime

Returns File modification time.

Returns:

  • (Time)

    File modification time.



123
124
125
126
127
# File 'ext/rpm/file.c', line 123

VALUE
rpm_file_get_mtime(VALUE file)
{
	return rb_ivar_get(file, id_mtime);
}

#netshared?Boolean

Returns True if the file is shared over the network.

Returns:

  • (Boolean)

    True if the file is shared over the network



317
318
319
320
321
322
# File 'ext/rpm/file.c', line 317

VALUE
rpm_file_is_netshared(VALUE file)
{
	return (NUM2INT(rb_ivar_get(file, id_state))
			== RPMFILE_STATE_NETSHARED) ? Qtrue : Qfalse;
}

#noreplace?Boolean

This flag is used to protect local modifications. If used, the file will not overwrite an existing file that has been modified. If the file has not been modified on disk, the rpm command will overwrite the file. But,

if the file has been modified on disk, the rpm command will copy the new file with an extra
file-name extension of .rpmnew.

Returns:

  • (Boolean)

    True if the file is marked as configuration not to be replaced



238
239
240
241
242
# File 'ext/rpm/file.c', line 238

VALUE
rpm_file_is_noreplace(VALUE file)
{
	return (NUM2INT(rb_ivar_get(file, id_attr)) & RPMFILE_NOREPLACE) ? Qtrue : Qfalse;
}

#notinstalled?Boolean

Returns True if the file is not installed.

Returns:

  • (Boolean)

    True if the file is not installed



307
308
309
310
311
312
# File 'ext/rpm/file.c', line 307

VALUE
rpm_file_is_notinstalled(VALUE file)
{
	return (NUM2INT(rb_ivar_get(file, id_state))
			== RPMFILE_STATE_NOTINSTALLED) ? Qtrue : Qfalse;
}

#ownerString

Returns File owner. Nil may be returned.

Returns:

  • (String)

    File owner. Nil may be returned.



132
133
134
135
136
# File 'ext/rpm/file.c', line 132

VALUE
rpm_file_get_owner(VALUE file)
{
	return rb_ivar_get(file, id_owner);
}

#pathString Also known as: to_s

Returns file path.

Returns:

  • (String)

    file path



84
85
86
87
88
# File 'ext/rpm/file.c', line 84

VALUE
rpm_file_get_path(VALUE file)
{
	return rb_ivar_get(file, id_path);
}

#rdevNumber

Returns Device type of the file.

Returns:

  • (Number)

    Device type of the file



150
151
152
153
154
# File 'ext/rpm/file.c', line 150

VALUE
rpm_file_get_rdev(VALUE file)
{
	return rb_ivar_get(file, id_rdev);
}

#readme?Boolean

Returns True if the file is a README.

Returns:

  • (Boolean)

    True if the file is a README



279
280
281
282
283
# File 'ext/rpm/file.c', line 279

VALUE
rpm_file_is_readme(VALUE file)
{
	return (NUM2INT(rb_ivar_get(file, id_attr)) & RPMFILE_README) ? Qtrue : Qfalse;
}

#replaced?Boolean

Returns True if the file is replaced during installation.

Returns:

  • (Boolean)

    True if the file is replaced during installation



297
298
299
300
301
302
# File 'ext/rpm/file.c', line 297

VALUE
rpm_file_is_replaced(VALUE file)
{
	return (NUM2INT(rb_ivar_get(file, id_state))
			== RPMFILE_STATE_REPLACED) ? Qtrue : Qfalse;
}

#sizeNumber

Returns File size.

Returns:

  • (Number)

    File size



114
115
116
117
118
# File 'ext/rpm/file.c', line 114

VALUE
rpm_file_get_size(VALUE file)
{
	return rb_ivar_get(file, id_size);
}

#specfile?Boolean

Returns True if the file is marked as a spec file.

Returns:

  • (Boolean)

    True if the file is marked as a spec file



247
248
249
250
251
# File 'ext/rpm/file.c', line 247

VALUE
rpm_file_is_specfile(VALUE file)
{
	return (NUM2INT(rb_ivar_get(file, id_attr)) & RPMFILE_SPECFILE) ? Qtrue : Qfalse;
}

#stateObject



171
172
173
174
175
# File 'ext/rpm/file.c', line 171

VALUE
rpm_file_get_state(VALUE file)
{
	return rb_ivar_get(file, id_state);
}

#symlink?Boolean

Returns True if the file is a symbolic link.

Returns:

  • (Boolean)

    True if the file is a symbolic link



180
181
182
183
184
# File 'ext/rpm/file.c', line 180

VALUE
rpm_file_is_symlink(VALUE file)
{
	return NIL_P(rb_ivar_get(file, id_link_to)) ? Qfalse : Qtrue;
}