├── .gitignore ├── CHANGELOG.rdoc ├── LICENSE ├── README.rdoc ├── Rakefile ├── ext ├── extconf.rb └── mkfifo.c ├── lib └── mkfifo │ └── version.rb └── mkfifo.gemspec /.gitignore: -------------------------------------------------------------------------------- 1 | ext/Makefile 2 | ext/*.o 3 | ext/*.so 4 | *.gem 5 | -------------------------------------------------------------------------------- /CHANGELOG.rdoc: -------------------------------------------------------------------------------- 1 | = Changelog 2 | 3 | == 0.1.0 4 | 5 | * File::mkfifo now raises +TypeError+ instead of +ArgumentError+ for 6 | an object of incorrect type. (Quintus) 7 | * File::mkfifo now accepts Pathname objects. (Quintus) 8 | * File::mkfifo now raises +IOError+ instead of +Exception+. (Quintus) 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 2 | Version 2, December 2004 3 | 4 | Copyright (C) 2004 Sam Hocevar 5 | 6 | Everyone is permitted to copy and distribute verbatim or modified 7 | copies of this license document, and changing it is allowed as long 8 | as the name is changed. 9 | 10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 12 | 13 | 0. You just DO WHAT THE FUCK YOU WANT TO. 14 | 15 | -------------------------------------------------------------------------------- /README.rdoc: -------------------------------------------------------------------------------- 1 | = mkfifo 2 | Binds the mkfifo(3) function to Ruby as a class method for Ruby’s 3 | built-in +File+ class. 4 | 5 | == Usage 6 | 7 | require "mkfifo" 8 | File.mkfifo('/path/to/file') 9 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler" 2 | require "rake" 3 | require "bundler/gem_tasks" 4 | 5 | -------------------------------------------------------------------------------- /ext/extconf.rb: -------------------------------------------------------------------------------- 1 | require 'mkmf' 2 | 3 | if have_func('mkfifo', %[sys/stat.h]) 4 | create_makefile('mkfifo') 5 | end 6 | -------------------------------------------------------------------------------- /ext/mkfifo.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | VALUE rb_cFile_mkfifo(int, VALUE*, VALUE); 6 | 7 | void 8 | Init_mkfifo(void) { 9 | rb_define_singleton_method(rb_cFile, "mkfifo", rb_cFile_mkfifo, -1); 10 | } 11 | 12 | /* Document-method: File::mkfifo 13 | * 14 | * call-seq: 15 | * mkfifo(path[, mode]) -> an_integer 16 | * 17 | * Creates a named pipe at +path+. Raises +SystemCallError+ if the 18 | * operation fails. 19 | * If +mode+ is given, creates +path+ with the permission. If it is 20 | * not given or _nil_, user and group are readable and writable. 21 | */ 22 | VALUE 23 | rb_cFile_mkfifo(int argc, VALUE *argv, VALUE self) { 24 | VALUE name; 25 | VALUE mode; 26 | mode_t perm = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP; 27 | 28 | #ifdef rb_check_arity 29 | rb_check_arity(argc, 1, 2); 30 | name = argv[0]; 31 | mode = argv[1]; 32 | #else 33 | rb_scan_args(argc, argv, "11", &name, &mode); 34 | #endif 35 | 36 | FilePathValue(name); 37 | if (!NIL_P(mode)) perm = NUM2MODET(mode); 38 | 39 | if (mkfifo(RSTRING_PTR(name), perm) < 0) { 40 | rb_sys_fail_str(name); 41 | } 42 | 43 | return INT2FIX(1); 44 | } 45 | -------------------------------------------------------------------------------- /lib/mkfifo/version.rb: -------------------------------------------------------------------------------- 1 | module Mkfifo 2 | VERSION = '0.1.1' 3 | end 4 | -------------------------------------------------------------------------------- /mkfifo.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | lib = File.expand_path('../lib/', __FILE__) 3 | $:.unshift lib unless $:.include?(lib) 4 | 5 | require 'mkfifo/version' 6 | 7 | Gem::Specification.new do |s| 8 | s.name = 'mkfifo' 9 | s.version = Mkfifo::VERSION 10 | s.author = 'shura' 11 | s.email = 'shura1991@gmail.com' 12 | s.homepage = 'http://github.com/shurizzle/ruby-mkfifo' 13 | s.platform = Gem::Platform::RUBY 14 | s.summary = 'Create named pipes (FIFOs) from Ruby' 15 | s.description =<<-EOF 16 | Provides Ruby's File class with a new method called ::mkfifo 17 | that creates a named pipe (FIFO). This gem is a simple C 18 | extension wrapping the *nixish mkfifo(3) function. 19 | EOF 20 | s.files = Dir.glob("{lib}/**/*") + Dir['ext/*.rb'] + Dir['ext/*.c'] 21 | s.require_paths = ["lib"] 22 | s.extensions = 'ext/extconf.rb' 23 | s.extra_rdoc_files = %w[README.rdoc CHANGELOG.rdoc ext/mkfifo.c] 24 | s.rdoc_options << "-m" << "README.rdoc" << "-t" << "ruby-mkfifo" 25 | s.has_rdoc = true 26 | end 27 | --------------------------------------------------------------------------------