示例#1
0
void			get_directory_content(t_list *dir, t_list **files, int options)
{
	DIR			*pdir;
	t_dir		*pdirent;
	char		*tmp;

	pdir = NULL;
	pdirent = NULL;
	if (!(tmp = set_file_path(NAME(dir), PATH(dir))))
		print_mem_error(errno);
	if ((pdir = opendir(tmp)))
	{
		while ((pdirent = readdir(pdir)))
		{
			if (pdirent)
				add_file(pdirent->d_name, files, tmp, options);
			else
				print_mem_error(errno);
		}
		closedir(pdir);
	}
	else
		print_opendir_error(tmp, errno);
	ft_strdel(&tmp);
	sort(*files, options);
}
示例#2
0
  void cpp_callback(const char* bundle_identifier,
                    const char* file_path) {
    auto application_ptr = std::make_shared<application>();
    if (bundle_identifier) {
      application_ptr->set_bundle_identifier(bundle_identifier);
    }
    if (file_path) {
      application_ptr->set_file_path(file_path);
    }

    enqueue_to_dispatcher([this, application_ptr] {
      frontmost_application_changed(application_ptr);
    });
  }
示例#3
0
/*
 * call-seq:
 *
 *	Kgio::File.tryopen(filename, [, mode [, perm]])	-> Kgio::File or Symbol
 *
 * Returns a Kgio::File object on a successful open.  +filename+ is a
 * path to any file on the filesystem.  If specified, +mode+ is a bitmask
 * of flags (see IO.sysopen) and +perm+ should be an octal number.
 *
 * This does not raise errors for most failures, but installs returns a
 * Ruby symbol for the constant in the Errno::* namespace.
 *
 * Common error symbols are:
 *
 * - :ENOENT
 * - :EACCES
 *
 * See your open(2) manpage for more information on open(2) errors.
 */
static VALUE s_tryopen(int argc, VALUE *argv, VALUE klass)
{
	int fd;
	VALUE pathname, flags, mode;
	struct open_args o;
	int retried = 0;
	VALUE rv;

	rb_scan_args(argc, argv, "12", &pathname, &flags, &mode);
	if (rb_respond_to(pathname, id_to_path))
		pathname = rb_funcall(pathname, id_to_path, 0);
	o.pathname = StringValueCStr(pathname);

	switch (TYPE(flags)) {
	case T_NIL: o.flags = O_RDONLY; break;
	case T_FIXNUM: o.flags = FIX2INT(flags); break;
	case T_BIGNUM: o.flags = NUM2INT(flags); break;
	default: rb_raise(rb_eArgError, "flags must be an Integer");
	}
	switch (TYPE(mode)) {
	case T_NIL: o.mode = 0666; break;
	case T_FIXNUM: o.mode = FIX2INT(mode); break;
	case T_BIGNUM: o.mode = NUM2INT(mode); break;
	default: rb_raise(rb_eArgError, "mode must be an Integer");
	}

retry:
	fd = (int)rb_thread_blocking_region(nogvl_open, &o, RUBY_UBF_IO, 0);
	if (fd < 0) {
		if (errno == EMFILE || errno == ENFILE || errno == ENOMEM) {
			rb_gc();
			if (retried)
				rb_sys_fail(o.pathname);
			retried = 1;
			goto retry;
		}
		if (fd < 0) {
			int saved_errno = errno;

			if (!st_lookup(errno2sym, (st_data_t)errno, &rv)) {
				errno = saved_errno;
				rb_sys_fail(o.pathname);
			}
			return rv;
		}
	}
	rv = rb_funcall(klass, id_for_fd, 1, INT2FIX(fd));
	set_file_path(rv, pathname);
	return rv;
}
示例#4
0
 void ProtoBufExport::InputChanged(clang::FileEntry const *file) {
     exportData([&](ct::proto::Envelope &env) {
         auto input = env.mutable_input();
         input->set_file_path(file->getName());
     });
 }