Higher-order bits may also be used to indicate the type of file (plain, directory, pipe., '.rb') #=> 'ruby' File. => true # match entire string File. Ruby script to create a.zip archive containing an entire directory tree. # file: ZipExample1.rb require 'rubygems' require 'chilkat' # Simple example showing how. Class: File (Ruby 2. Converts a pathname to an absolute pathname. Relative paths are referenced. If the given pathname starts with a “~” it is NOT. File. absolute_path("~oracle/bin"). VALUE. rb_file_s_absolute_path(int argc, const VALUE *argv). VALUE fname, dname. Qnil). rb_scan_args(argc, argv, "1. Returns the last access time for the named file as a Time object). IO object. File. atime("testfile"). VALUE. rb_file_s_atime(VALUE klass, VALUE fname). File. Path. Value(fname). Returns the last component of the filename given in file_name. File: :SEPARATOR and. File: :ALT_SEPARATOR as the separator when. File: :ALT_SEPARATOR is not nil. If. suffix is given and present at the end of file_name, it. If suffix is “.*”, any extension will be removed. File. basename("/home/gumby/work/ruby. File. basename("/home/gumby/work/ruby. File. basename("/home/gumby/work/ruby. VALUE. rb_file_s_basename(int argc, VALUE *argv). To create a tar archive of an entire directory including all files and sub. # zip -rv9 myzipfile.zip /mydir. Ruby Could Replace my Python Crawler Pretty. VALUE fname, fext, basename. String. Value(fext). Download the Pokemon - Ruby Version (U) ROM for Gameboy Advance (GBA). Region: United States of America. Works with Android, PC, Mac devices. Class : Dir - Ruby 2.3.0. Home; Core; Std-lib; Downloads. The directory used in these examples contains the two regular files (config.h and main.rb). As basic as this seems, I simply can't manage to copy the contents of one file to another. Here is my code thus far: #!/usr/bin/ruby Dir.chdir( '/mnt/Shared/minecraft. ZipFile is modeled after java.util.zip.ZipFile from the Java SDK. The most important methods are those inherited from ZipCentralDirectory for accessing information. How can I remove '/' on the beginning of the links using ruby. Here is the code section using zip. /' starting paths with relative. folder or zip file and. Ruby 2.0.0-p648 (x64) Other Useful Downloads 7-Zip Archives. Ruby 2.2.4; Ruby 2.2.4. If you would like to use the 7-Zip archived versions or the Ruby documentation. Hi, I am looking at copying a folder and its contents from one destination to another. FileUtils.copy('C:/rspec_reports/javascripts', 'C:/rspec_reports/ javascripts. File. Path. String. Value(fname). if (NIL_P(fext) || !(enc = rb_enc_compatible(fname, fext))) {. Qnil. if ((n = RSTRING_LEN(fname)) == 0 || !*(name = RSTRING_PTR(fname))). NIL_P(fext)) {. f = n. String. Value. CStr(fext). RSTRING_LEN(fext), enc))) {. RB_GC_GUARD(fext). RSTRING_LEN(fname)) return rb_str_new_shared(fname). OBJ_INFECT(basename, fname). Returns the birth time for the named file. IO object. File. birthtime("testfile") If the platform doesn’t have birthtime, raises Not. Implemented. Error. VALUE. rb_file_s_birthtime(VALUE klass, VALUE fname). File. Path. Value(fname). Returns true if the named file is a block device. IO object. static VALUE. VALUE obj, VALUE fname). S_ISBLK. # ifdef S_IFBLK. S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK). S_ISBLK(m) (0) /* anytime false */. Qfalse. if (S_ISBLK(st. Qtrue. return Qfalse. Returns true if the named file is a character device. IO object. static VALUE. VALUE obj, VALUE fname). S_ISCHR. # define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR). Qfalse. if (S_ISCHR(st. Qtrue. return Qfalse. Changes permission bits on the named file(s) to the bit pattern represented. Actual effects are operating system dependent (see. On Unix systems, see chmod(2). Returns the number of files processed. File. chmod(0. 64. VALUE. rb_file_s_chmod(int argc, VALUE *argv). VALUE vmode. VALUE rest. NUM2. INT(vmode). LONG2. FIX(n). chown(owner_int, group_int, file_name.. Changes the owner and group of the named file(s) to the given numeric owner. Only a process with superuser privileges may change the. The current owner of a file may change the file’s group to. A nil or - 1 owner or. Returns the number of files processed. File. chown(nil, 1. VALUE. rb_file_s_chown(int argc, VALUE *argv). VALUE o, g, rest. LONG2. FIX(n). ctime(file_name) → timeclick to toggle source. Returns the change time for the named file (the time at which directory. IO object. Note that on Windows (NTFS), returns creation time (birth time). File. ctime("testfile"). VALUE. rb_file_s_ctime(VALUE klass, VALUE fname). File. Path. Value(fname). Deletes the named files, returning the number of names passed as arguments. Raises an exception on any error. See also Dir: :rmdir. VALUE. rb_file_s_unlink(VALUE klass, VALUE args). LONG2. FIX(n). directory?(file_name) → true or falseclick to toggle source. Returns true if the named file is a directory, or a symlink. IO object. File. directory?("."). VALUE. rb_file_directory_p(VALUE obj, VALUE fname). S_ISDIR. # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR). Qfalse. if (S_ISDIR(st. Qtrue. return Qfalse. Returns all components of the filename given in file_name except. The filename can be formed using both. File: :SEPARATOR and File: :ALT_SEPARATOR as the. File: :ALT_SEPARATOR is not nil. File. dirname("/home/gumby/work/ruby. VALUE. rb_file_s_dirname(VALUE klass, VALUE fname). Returns true if the named file is executable by the effective. See eaccess(3). static VALUE. VALUE obj, VALUE fname). File. Path. Value(fname). String. Value. CStr(fname), X_OK) < 0) return Qfalse. Qtrue. executable_real?(file_name) → true or falseclick to toggle source. Returns true if the named file is executable by the real user. See access(3). static VALUE. VALUE obj, VALUE fname). File. Path. Value(fname). String. Value. CStr(fname), X_OK) < 0) return Qfalse. Qtrue. exist?(file_name) → true or falseclick to toggle source. Return true if the named file exists. IO object.“file exists” means that stat() or fstat() system call is successful. VALUE. rb_file_exist_p(VALUE obj, VALUE fname). Qfalse. return Qtrue. Deprecated method. Don’t use. static VALUE. VALUE obj, VALUE fname). File. Test#". if (obj == rb_m. File. Test) {. s = "File. Test.". else if (obj == rb_c. File ||. (RB_TYPE_P(obj, T_CLASS) & &. RTEST(rb_class_inherited_p(obj, rb_c. File)))) {. s = "File.". Converts a pathname to an absolute pathname. Relative paths are referenced. The given pathname may start with a “~”, which. HOME must be set correctly). File. expand_path("~oracle/bin") A simple example of using dir_string is as follows. File. expand_path("ruby", "/usr/bin") A more complex example which also resolves parent directory is as follows. Suppose we are in bin/mygem and want the absolute path of lib/mygem. File. expand_path("././lib/mygem. FILE__). So first it resolves the parent of __FILE__, that is bin/, then go to the. VALUE. rb_file_s_expand_path(int argc, const VALUE *argv). VALUE fname, dname. Qnil). rb_scan_args(argc, argv, "1. Returns the extension (the portion of file name in path. If path is a dotfile, or starts with a period, then the. An empty string will also be returned when the period is the last character. File. extname("test. File. extname("a/b/d/test. File. extname(". a/b/d/test. File. extname("foo.") File. File. extname(". profile") File. VALUE. rb_file_s_extname(VALUE klass, VALUE fname). VALUE extname. File. Path. String. Value(fname). String. Value. CStr(fname). RSTRING_LEN(fname). OBJ_INFECT(extname, fname). Returns true if the named file exists and is a. IO object. If the file argument is a symbolic link, it will resolve the. VALUE. rb_file_file_p(VALUE obj, VALUE fname). Qfalse. if (S_ISREG(st. Qtrue. return Qfalse. Returns true if path matches against pattern. The pattern is not a regular expression; instead it follows rules similar. It may contain the following metacharacters: *Matches any file. Can be restricted by other values in the glob. Equivalent. to / .* /x in regexp.*Matches all files regular filesc*Matches all files beginning with c*c. Matches all files ending with c*c*Matches all files that have c in them (including at the. To match hidden files (that start with a . File: :FNM_DOTMATCH flag.**Matches directories recursively or files expansively.? Matches any one character. Equivalent to /.{1}/ in regexp.[set]Matches any one character in set. Behaves exactly like. Regexp, including set negation. Escapes the next metacharacter.{a,b}Matches pattern a and pattern b if File: :FNM_EXTGLOB flag is enabled. Behaves like a Regexp union. OR of the FNM_XXX constants. The same glob pattern and flags are used by Dir. Examples: File. fnmatch('cat', 'cat') File. File. fnmatch('c{at,ub}s', 'cats') File. File: :FNM_EXTGLOB) File. File. fnmatch('c?? File. fnmatch('c*', 'cats') File. File. fnmatch('ca[a- z]', 'cat') File. File. fnmatch('cat', 'CAT') File. CAT', File: :FNM_CASEFOLD) File. File: :FNM_PATHNAME) File. File: :FNM_PATHNAME) File. File: :FNM_PATHNAME) File. File. fnmatch('\a', 'a') File. File: :FNM_NOESCAPE) File. File. fnmatch('*', '. File. fnmatch('*', '. File: :FNM_DOTMATCH) File. File. fnmatch(rbfiles, 'main. File. fnmatch(rbfiles, './main. File. fnmatch(rbfiles, 'lib/song. File. fnmatch('**. File. fnmatch('**. File. fnmatch('**. File. fnmatch('*', 'dave/. File. fnmatch(pattern, 'dave/. File: :FNM_PATHNAME) File. File: :FNM_PATHNAME|File: :FNM_DOTMATCH) pattern = '**''/''foo'File. File: :FNM_PATHNAME) File. File: :FNM_PATHNAME) File. File: :FNM_PATHNAME) File. File: :FNM_PATHNAME) File. File: :FNM_PATHNAME|File: :FNM_DOTMATCH). VALUE. file_s_fnmatch(int argc, VALUE *argv, VALUE obj). VALUE pattern, path. VALUE rflags. if (rb_scan_args(argc, argv, "2. NUM2. INT(rflags). String. Value(pattern). File. Path. String. Value(path). if (flags & FNM_EXTGLOB) {. RSTRING_PTR(pattern), flags, fnmatch_brace. VALUE)& args, rb_enc_get(pattern)) > 0). Qtrue. rb_encoding *enc = rb_enc_compatible(pattern, path). Qfalse. if (fnmatch(RSTRING_PTR(pattern), enc, RSTRING_PTR(path), flags) == 0). Qtrue. RB_GC_GUARD(pattern). Qfalse. fnmatch?( pattern, path, [flags] ) → (true or false)click to toggle source. Returns true if path matches against pattern. The pattern is not a regular expression; instead it follows rules similar. It may contain the following metacharacters: *Matches any file. Can be restricted by other values in the glob. Equivalent. to / .* /x in regexp.*Matches all files regular filesc*Matches all files beginning with c*c. Matches all files ending with c*c*Matches all files that have c in them (including at the. To match hidden files (that start with a . Equivalent to /.{1}/ in regexp.[set]Matches any one character in set. Behaves exactly like. Regexp, including set negation. Escapes the next metacharacter.{a,b}Matches pattern a and pattern b if File: :FNM_EXTGLOB flag is enabled. Behaves like a Regexp union. OR of the FNM_XXX constants. The same glob pattern and flags are used by Dir. Examples: File. fnmatch('cat', 'cat') File. File. fnmatch('c{at,ub}s', 'cats') File. File: :FNM_EXTGLOB) File. File. fnmatch('c?? File. fnmatch('c*', 'cats') File. File. fnmatch('ca[a- z]', 'cat') File. File. fnmatch('cat', 'CAT') File. CAT', File: :FNM_CASEFOLD) File. File: :FNM_PATHNAME) File. File: :FNM_PATHNAME) File. File: :FNM_PATHNAME) File. File. fnmatch('\a', 'a') File. File: :FNM_NOESCAPE) File. File. fnmatch('*', '. File. fnmatch('*', '. File: :FNM_DOTMATCH) File. File. fnmatch(rbfiles, 'main. File. fnmatch(rbfiles, './main.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
September 2016
Categories |