• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ os_open函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中os_open函数的典型用法代码示例。如果您正苦于以下问题:C++ os_open函数的具体用法?C++ os_open怎么用?C++ os_open使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了os_open函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: os_find_u_boot

int os_find_u_boot(char *fname, int maxlen)
{
	struct sandbox_state *state = state_get_current();
	const char *progname = state->argv[0];
	int len = strlen(progname);
	const char *suffix;
	char *p;
	int fd;

	if (len >= maxlen || len < 4)
		return -ENOSPC;

	strcpy(fname, progname);
	suffix = fname + len - 4;

	/* If we are TPL, boot to SPL */
	if (!strcmp(suffix, "-tpl")) {
		fname[len - 3] = 's';
		fd = os_open(fname, O_RDONLY);
		if (fd >= 0) {
			close(fd);
			return 0;
		}

		/* Look for 'u-boot-tpl' in the tpl/ directory */
		p = strstr(fname, "/tpl/");
		if (p) {
			p[1] = 's';
			fd = os_open(fname, O_RDONLY);
			if (fd >= 0) {
				close(fd);
				return 0;
			}
		}
		return -ENOENT;
	}

	/* Look for 'u-boot' in the same directory as 'u-boot-spl' */
	if (!strcmp(suffix, "-spl")) {
		fname[len - 4] = '\0';
		fd = os_open(fname, O_RDONLY);
		if (fd >= 0) {
			close(fd);
			return 0;
		}
	}

	/* Look for 'u-boot' in the parent directory of spl/ */
	p = strstr(fname, "/spl/");
	if (p) {
		strcpy(p, p + 4);
		fd = os_open(fname, O_RDONLY);
		if (fd >= 0) {
			close(fd);
			return 0;
		}
	}

	return -ENOENT;
}
开发者ID:danielschwierzeck,项目名称:u-boot-lantiq,代码行数:60,代码来源:os.c


示例2: util_file_map_whole

/*
 * util_file_map_whole -- maps the entire file into memory
 */
void *
util_file_map_whole(const char *path)
{
	LOG(3, "path \"%s\"", path);

	int fd;
	int olderrno;
	void *addr = NULL;

	if ((fd = os_open(path, O_RDWR)) < 0) {
		ERR("!open \"%s\"", path);
		return NULL;
	}

	ssize_t size = util_file_get_size(path);
	if (size < 0) {
		LOG(2, "cannot determine file length \"%s\"", path);
		goto out;
	}

	addr = util_map(fd, (size_t)size, MAP_SHARED, 0, 0, NULL);
	if (addr == NULL) {
		LOG(2, "failed to map entire file \"%s\"", path);
		goto out;
	}

out:
	olderrno = errno;
	(void) os_close(fd);
	errno = olderrno;

	return addr;
}
开发者ID:krzycz,项目名称:nvml,代码行数:36,代码来源:file.c


示例3: server_open

static int server_open( u8 *p )
{
  const char *filename;
  int mode, flags, fd;
  char separator[ 2 ] = { PLATFORM_PATH_SEPARATOR, 0 };
  
  // Validate request
  log_msg( "server_open: request handler starting\n" );
  if( remotefs_open_read_request( p, &filename, &flags, &mode ) == ELUARPC_ERR )
  {
    log_msg( "server_open: unable to read request\n" );
    return SERVER_ERR;
  }
  // Get real filename
  server_fullname[ 0 ] = server_fullname[ PLATFORM_MAX_FNAME_LEN ] = 0;
  strncpy( server_fullname, server_basedir, PLATFORM_MAX_FNAME_LEN );
  if( filename && strlen( filename ) > 0 )
  {
    if( server_fullname[ strlen( server_fullname ) - 1 ] != PLATFORM_PATH_SEPARATOR )
      strncat( server_fullname, separator, PLATFORM_MAX_FNAME_LEN );
    strncat( server_fullname, filename, PLATFORM_MAX_FNAME_LEN );
  }
  log_msg( "server_open: full file path is %s\n", server_fullname ); 
  fd = os_open( server_fullname, flags, mode );
  log_msg( "server_open: OS file handler is %d\n", fd );
  remotefs_open_write_response( p, fd );
  return SERVER_OK;
}
开发者ID:elua,项目名称:moonlight,代码行数:28,代码来源:server.c


示例4: sandbox_fs_write_at

int sandbox_fs_write_at(const char *filename, loff_t pos, void *buffer,
			loff_t towrite, loff_t *actwrite)
{
	ssize_t size;
	int fd, ret;

	fd = os_open(filename, OS_O_RDWR | OS_O_CREAT);
	if (fd < 0)
		return fd;
	ret = os_lseek(fd, pos, OS_SEEK_SET);
	if (ret == -1) {
		os_close(fd);
		return ret;
	}
	size = os_write(fd, buffer, towrite);
	os_close(fd);

	if (size == -1) {
		ret = -1;
	} else {
		ret = 0;
		*actwrite = size;
	}

	return ret;
}
开发者ID:OpenNoah,项目名称:u-boot,代码行数:26,代码来源:sandboxfs.c


示例5: util_file_create

/*
 * util_file_create -- create a new memory pool file
 */
int
util_file_create(const char *path, size_t size, size_t minsize)
{
	LOG(3, "path \"%s\" size %zu minsize %zu", path, size, minsize);

	ASSERTne(size, 0);

	if (size < minsize) {
		ERR("size %zu smaller than %zu", size, minsize);
		errno = EINVAL;
		return -1;
	}

	if (((os_off_t)size) < 0) {
		ERR("invalid size (%zu) for os_off_t", size);
		errno = EFBIG;
		return -1;
	}

	int fd;
	int mode;
	int flags = O_RDWR | O_CREAT | O_EXCL;
#ifndef _WIN32
	mode = 0;
#else
	mode = S_IWRITE | S_IREAD;
	flags |= O_BINARY;
#endif

	/*
	 * Create file without any permission. It will be granted once
	 * initialization completes.
	 */
	if ((fd = os_open(path, flags, mode)) < 0) {
		ERR("!open \"%s\"", path);
		return -1;
	}

	if ((errno = os_posix_fallocate(fd, 0, (os_off_t)size)) != 0) {
		ERR("!posix_fallocate \"%s\", %zu", path, size);
		goto err;
	}

	/* for windows we can't flock until after we fallocate */
	if (os_flock(fd, OS_LOCK_EX | OS_LOCK_NB) < 0) {
		ERR("!flock \"%s\"", path);
		goto err;
	}

	return fd;

err:
	LOG(4, "error clean up");
	int oerrno = errno;
	if (fd != -1)
		(void) os_close(fd);
	os_unlink(path);
	errno = oerrno;
	return -1;
}
开发者ID:krzycz,项目名称:nvml,代码行数:63,代码来源:file.c


示例6: DI_Config_Save

s32 DI_Config_Save(struct dipConfigState *cfg)
{
	s32 fd, ret;

	/* Create config file */
	__Config_Create(__dip_cfg_filename);

	/* Open config file */
	fd = os_open(__dip_cfg_filename, ISFS_OPEN_WRITE);
	if (fd < 0)
		return fd;

	/* Write config */
	ret = os_write(fd, cfg, sizeof(*cfg));

	/* Write frag list */
	if (ret == sizeof(*cfg)) {
		if (cfg->mode == MODE_FRAG) {
			s32 ret2 = os_write(fd, &fraglist_data, cfg->frag_size);
			if (ret2 < 0)
				ret = ret2;
			else
				ret += ret2;
		}
	}

	/* Close config */
	os_close(fd);

	return ret;
}
开发者ID:TCCQ,项目名称:d2x-cios,代码行数:31,代码来源:config.c


示例7: os_nodetype

/// Check what `name` is:
/// @return NODE_NORMAL: file or directory (or doesn't exist)
///         NODE_WRITABLE: writable device, socket, fifo, etc.
///         NODE_OTHER: non-writable things
int os_nodetype(const char *name)
{
#ifdef WIN32
  // Edge case from Vim os_win32.c:
  // We can't open a file with a name "\\.\con" or "\\.\prn", trying to read
  // from it later will cause Vim to hang. Thus return NODE_WRITABLE here.
  if (STRNCMP(name, "\\\\.\\", 4) == 0) {
    return NODE_WRITABLE;
  }
#endif

  uv_stat_t statbuf;
  if (0 != os_stat(name, &statbuf)) {
    return NODE_NORMAL;  // File doesn't exist.
  }

#ifndef WIN32
  // libuv does not handle BLK and DIR in uv_handle_type.
  //    Related: https://github.com/joyent/libuv/pull/1421
  if (S_ISREG(statbuf.st_mode) || S_ISDIR(statbuf.st_mode)) {
    return NODE_NORMAL;
  }
  if (S_ISBLK(statbuf.st_mode)) {  // block device isn't writable
    return NODE_OTHER;
  }
#endif

  // Vim os_win32.c:mch_nodetype does this (since patch 7.4.015):
  //    if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) {
  //      wn = enc_to_utf16(name, NULL);
  //      hFile = CreatFile(wn, ...)
  // to get a HANDLE. But libuv just calls win32's _get_osfhandle() on the fd we
  // give it. uv_fs_open calls fs__capture_path which does a similar dance and
  // saves us the hassle.

  int nodetype = NODE_WRITABLE;
  int fd = os_open(name, O_RDONLY, 0);
  switch(uv_guess_handle(fd)) {
    case UV_TTY:         // FILE_TYPE_CHAR
      nodetype = NODE_WRITABLE;
      break;
    case UV_FILE:        // FILE_TYPE_DISK
      nodetype = NODE_NORMAL;
      break;
    case UV_NAMED_PIPE:  // not handled explicitly in Vim os_win32.c
    case UV_UDP:         // unix only
    case UV_TCP:         // unix only
    case UV_UNKNOWN_HANDLE:
    default:
#ifdef WIN32
      nodetype = NODE_NORMAL;
#else
      nodetype = NODE_WRITABLE;  // Everything else is writable?
#endif
      break;
  }

  close(fd);
  return nodetype;
}
开发者ID:DINKIN,项目名称:neovim,代码行数:64,代码来源:fs.c


示例8: usbstorage_Init

bool usbstorage_Init(void)
{
	s32 ret;

	/* Already open */
	if (fd >= 0)
		return true;

	/* Open USB device */
	fd = os_open(fs, 0);
	if (fd < 0)
		return false;

	/* Initialize USB storage */
	os_ioctlv(fd, USB_IOCTL_UMS_INIT, 0, 0, NULL);

	/* Get device capacity */
	ret = __usbstorage_GetCapacity(NULL);
	if (ret <= 0)
		goto err;

	return true;

err:
	/* Close USB device */
	usbstorage_Shutdown();	

	return false;
}
开发者ID:spacemanspiff,项目名称:uLoader,代码行数:29,代码来源:usbstorage.c


示例9: device_dax_size

/*
 * device_dax_size -- (internal) checks the size of a given dax device
 */
static ssize_t
device_dax_size(const char *path)
{
	LOG(3, "path \"%s\"", path);

	os_stat_t st;
	int olderrno;

	if (os_stat(path, &st) < 0) {
		ERR("!stat \"%s\"", path);
		return -1;
	}

	char spath[PATH_MAX];
	snprintf(spath, PATH_MAX, "/sys/dev/char/%u:%u/size",
		os_major(st.st_rdev), os_minor(st.st_rdev));

	LOG(4, "device size path \"%s\"", spath);

	int fd = os_open(spath, O_RDONLY);
	if (fd < 0) {
		ERR("!open \"%s\"", spath);
		return -1;
	}

	ssize_t size = -1;

	char sizebuf[MAX_SIZE_LENGTH + 1];
	ssize_t nread;
	if ((nread = read(fd, sizebuf, MAX_SIZE_LENGTH)) < 0) {
		ERR("!read");
		goto out;
	}

	sizebuf[nread] = 0; /* null termination */

	char *endptr;

	olderrno = errno;
	errno = 0;

	size = strtoll(sizebuf, &endptr, 0);
	if (endptr == sizebuf || *endptr != '\n' ||
	    ((size == LLONG_MAX || size == LLONG_MIN) && errno == ERANGE)) {
		ERR("invalid device size %s", sizebuf);
		size = -1;
		goto out;
	}

	errno = olderrno;

out:
	olderrno = errno;
	(void) os_close(fd);
	errno = olderrno;

	LOG(4, "device size %zu", size);
	return size;
}
开发者ID:krzycz,项目名称:nvml,代码行数:62,代码来源:file.c


示例10: util_file_open

/*
 * util_file_open -- open a memory pool file
 */
int
util_file_open(const char *path, size_t *size, size_t minsize, int flags)
{
	LOG(3, "path \"%s\" size %p minsize %zu flags %d", path, size, minsize,
			flags);

	int oerrno;
	int fd;

#ifdef _WIN32
	flags |= O_BINARY;
#endif

	if ((fd = os_open(path, flags)) < 0) {
		ERR("!open \"%s\"", path);
		return -1;
	}

	if (os_flock(fd, OS_LOCK_EX | OS_LOCK_NB) < 0) {
		ERR("!flock \"%s\"", path);
		(void) os_close(fd);
		return -1;
	}

	if (size || minsize) {
		if (size)
			ASSERTeq(*size, 0);

		ssize_t actual_size = util_file_get_size(path);
		if (actual_size < 0) {
			ERR("stat \"%s\": negative size", path);
			errno = EINVAL;
			goto err;
		}

		if ((size_t)actual_size < minsize) {
			ERR("size %zu smaller than %zu",
					(size_t)actual_size, minsize);
			errno = EINVAL;
			goto err;
		}

		if (size) {
			*size = (size_t)actual_size;
			LOG(4, "actual file size %zu", *size);
		}
	}

	return fd;
err:
	oerrno = errno;
	if (os_flock(fd, OS_LOCK_UN))
		ERR("!flock unlock");
	(void) os_close(fd);
	errno = oerrno;
	return -1;
}
开发者ID:krzycz,项目名称:nvml,代码行数:60,代码来源:file.c


示例11: DI_Config_Load

s32 DI_Config_Load(struct dipConfigState *cfg)
{
	s32 fd, ret;

#ifdef DEBUG
	svc_write("DIP: Config_Load(): Loading config file ");
	svc_write(__dip_cfg_filename);
	svc_write("\n");
#endif

	/* Open config file */
	fd = os_open(__dip_cfg_filename, ISFS_OPEN_READ);

#ifdef DEBUG
	svc_write("DIP: Config_Load(): Config file ");
	svc_write(fd < 0 ? "NOT found\n" : "found\n");
#endif

	if (fd < 0)
		return fd;

	/* Read config */
	ret = os_read(fd, cfg, sizeof(struct dipConfigState));

	if (ret == sizeof(struct dipConfigState)) {
		if (cfg->mode == MODE_FRAG) {
			s32 ret2;

			/* Read frag list */
			memset(&fraglist_data, 0, sizeof(fraglist_data));
			if (cfg->frag_size > sizeof(fraglist_data)) {
				ret2 = -1;
			} else {	   
				ret2 = os_read(fd, &fraglist_data, cfg->frag_size);
			}
			if (ret2 != cfg->frag_size)
				ret = -1;
		}
	}
	else if (ret >= 0)
		ret = -1;

	/* Close config */
	os_close(fd);

	/* Delete config file */
	__Config_Delete(__dip_cfg_filename);

#ifdef DEBUG
	if (ret < 0)
		svc_write("DIP: Config_Load(): Config file has unexpected size!!!\n");
#endif

	return ret;
}
开发者ID:TCCQ,项目名称:d2x-cios,代码行数:55,代码来源:config.c


示例12: get_elf_platform_path

static bool
get_elf_platform_path(const char *exe_path, dr_platform_t *platform)
{
    file_t fd = os_open(exe_path, OS_OPEN_READ);
    bool res = false;
    if (fd != INVALID_FILE) {
        res = get_elf_platform(fd, platform);
        os_close(fd);
    }
    return res;
}
开发者ID:cherry-wb,项目名称:dr-vis,代码行数:11,代码来源:injector.c


示例13: sandbox_flash_probe

static int sandbox_flash_probe(struct udevice *dev)
{
	struct sandbox_flash_plat *plat = dev_get_platdata(dev);
	struct sandbox_flash_priv *priv = dev_get_priv(dev);

	priv->fd = os_open(plat->pathname, OS_O_RDONLY);
	if (priv->fd != -1)
		return os_get_filesize(plat->pathname, &priv->file_size);

	return 0;
}
开发者ID:frawang,项目名称:u-boot,代码行数:11,代码来源:sandbox_flash.c


示例14: sandbox_sf_setup

static int sandbox_sf_setup(void **priv, const char *spec)
{
	/* spec = idcode:file */
	struct sandbox_spi_flash *sbsf;
	const char *file;
	size_t i, len, idname_len;
	const struct sandbox_spi_flash_data *data;

	file = strchr(spec, ':');
	if (!file) {
		printf("sandbox_sf: unable to parse file\n");
		goto error;
	}
	idname_len = file - spec;
	++file;

	for (i = 0; i < ARRAY_SIZE(sandbox_sf_flashes); ++i) {
		data = &sandbox_sf_flashes[i];
		len = strlen(data->name);
		if (idname_len != len)
			continue;
		if (!memcmp(spec, data->name, len))
			break;
	}
	if (i == ARRAY_SIZE(sandbox_sf_flashes)) {
		printf("sandbox_sf: unknown flash '%*s'\n", (int)idname_len,
		       spec);
		goto error;
	}

	if (sandbox_sf_0xff[0] == 0x00)
		memset(sandbox_sf_0xff, 0xff, sizeof(sandbox_sf_0xff));

	sbsf = calloc(sizeof(*sbsf), 1);
	if (!sbsf) {
		printf("sandbox_sf: out of memory\n");
		goto error;
	}

	sbsf->fd = os_open(file, 02);
	if (sbsf->fd == -1) {
		free(sbsf);
		printf("sandbox_sf: unable to open file '%s'\n", file);
		goto error;
	}

	sbsf->data = data;

	*priv = sbsf;
	return 0;

 error:
	return 1;
}
开发者ID:AnAtom,项目名称:u-boot-sunxi,代码行数:54,代码来源:sandbox.c


示例15: util_file_zero

/*
 * util_file_zero -- zeroes the specified region of the file
 */
int
util_file_zero(const char *path, os_off_t off, size_t len)
{
	LOG(3, "path \"%s\" off %ju len %zu", path, off, len);

	int fd;
	int olderrno;
	int ret = 0;

	if ((fd = os_open(path, O_RDWR)) < 0) {
		ERR("!open \"%s\"", path);
		return -1;
	}

	ssize_t size = util_file_get_size(path);
	if (size < 0) {
		LOG(2, "cannot determine file length \"%s\"", path);
		ret = -1;
		goto out;
	}

	if (off > size) {
		LOG(2, "offset beyond file length, %ju > %ju", off, size);
		ret = -1;
		goto out;
	}

	if ((size_t)off + len > (size_t)size) {
		LOG(2, "requested size of write goes beyond the file length, "
					"%zu > %zu", (size_t)off + len, size);
		LOG(4, "adjusting len to %zu", size - off);
		len = (size_t)(size - off);
	}

	void *addr = util_map(fd, (size_t)size, MAP_SHARED, 0, 0, NULL);
	if (addr == NULL) {
		LOG(2, "failed to map entire file \"%s\"", path);
		ret = -1;
		goto out;
	}

	/* zero initialize the specified region */
	memset((char *)addr + off, 0, len);

	util_unmap(addr, (size_t)size);

out:
	olderrno = errno;
	(void) os_close(fd);
	errno = olderrno;

	return ret;
}
开发者ID:krzycz,项目名称:nvml,代码行数:56,代码来源:file.c


示例16: pf_read_package_file

static void
pf_read_package_file (PFunArgs)
{
  char *filename = mhtml_evaluate_string (get_positional_arg (vars, 0));
  int packages_read = 0;

  if (!empty_string_p (filename))
    {
      int fd;

      /* If the filename specification doesn't start with a slash, then
	 add the current directory and relative path. */
      if (*filename != '/')
	{
	  BPRINTF_BUFFER *temp = bprintf_create_buffer ();
	  char *pre = pagefunc_get_variable ("mhtml::include-prefix");
	  char *rel = pagefunc_get_variable ("mhtml::relative-prefix");

	  if (pre)
	    {
	      if (!rel) rel = "";
	      bprintf (temp, "%s%s/%s", pre, rel, filename);
	      free (filename);
	      filename = temp->buffer;
	      free (temp);
	    }
	}

      fd = os_open (filename, O_RDONLY, 0666);

      if (fd > -1)
	{
	  Package *pack;

	  while ((pack = symbol_load_package (fd)) != (Package *)NULL)
	    packages_read++;

	  close (fd);
	}
    }

  if (filename) free (filename);

  if (packages_read)
    {
      bprintf_insert (page, start, "%d", packages_read);

      if (mhtml_user_keywords == (Package *)NULL)
	mhtml_user_keywords = 
	  symbol_get_package_hash ("*user-functions*", 577);
    }
}
开发者ID:AOSC-Dev,项目名称:metahtml,代码行数:52,代码来源:prims.c


示例17: module_file_has_module_header

bool
module_file_has_module_header(const char *filename)
{
    bool res = false;
    struct mach_header hdr;
    file_t fd = os_open(filename, OS_OPEN_READ);
    if (fd == INVALID_FILE)
        return false;
    if (os_read(fd, &hdr, sizeof(hdr)) == sizeof(hdr) &&
        is_macho_header((app_pc)&hdr, sizeof(hdr)))
        res = true;
    os_close(fd);
    return res;
}
开发者ID:djmott,项目名称:dynamorio,代码行数:14,代码来源:module_macho.c


示例18: app_open

int app_open(const char *path, int oflag, ...)
{
    int flags = IS_FILE;
    if (oflag & O_ACCMODE)
        flags |= NEED_WRITE;

    char realpath[MAX_PATH];
    const char *fpath = handle_special_dirs(path, flags, realpath,
                                            sizeof (realpath));
    if (!fpath)
        FILE_ERROR_RETURN(ENAMETOOLONG, -1);

    return os_open(fpath, oflag __OPEN_MODE_ARG);
}
开发者ID:RichJames,项目名称:rockbox,代码行数:14,代码来源:filesystem-app.c


示例19: check_cpu_cache

/*
 * check_cpu_cache -- (internal) check if file contains "cpu_cache" entry
 */
static int
check_cpu_cache(const char *domain_path)
{
	LOG(3, "domain_path: %s", domain_path);

	char domain_value[DOMAIN_VALUE_LEN];
	int domain_fd;
	int cpu_cache = 0;

	if ((domain_fd = os_open(domain_path, O_RDONLY)) < 0) {
		LOG(1, "!open(\"%s\", O_RDONLY)", domain_path);
			goto end;
	}
	ssize_t len = read(domain_fd, domain_value,
			DOMAIN_VALUE_LEN);

	if (len < 0) {
		ERR("!read(%d, %p, %d)", domain_fd,
			domain_value, DOMAIN_VALUE_LEN);
		cpu_cache = -1;
		goto end;
	} else if (len == 0) {
		errno = ENODATA;
		ERR("read(%d, %p, %d) empty string",
			domain_fd, domain_value,
			DOMAIN_VALUE_LEN);
		cpu_cache = -1;
		goto end;
	} else if (domain_value[len - 1] != '\n') {
		ERR("!read(%d, %p, %d) invalid format",
			domain_fd, domain_value,
			DOMAIN_VALUE_LEN);
		cpu_cache = -1;
		goto end;
	}

	LOG(15, "detected persistent_domain: %s", domain_value);
	if (strncmp(domain_value, "cpu_cache", strlen("cpu_cache")) == 0) {
		LOG(15, "cpu_cache in persistent_domain: %s", domain_path);
		cpu_cache = 1;
	} else {
		LOG(15, "cpu_cache not in persistent_domain: %s", domain_path);
		cpu_cache = 0;
	}

end:
	if (domain_fd >= 0)
		os_close(domain_fd);
	return cpu_cache;
}
开发者ID:lplewa,项目名称:nvml,代码行数:53,代码来源:os_auto_flush_linux.c


示例20: pf_write_package_file

static void
pf_write_package_file (PFunArgs)
{
  char *filename = mhtml_evaluate_string (get_positional_arg (vars, 0));
  char *flagged = mhtml_evaluate_string (get_value (vars, "flagged"));
  char *no_source = mhtml_evaluate_string (get_value (vars, "no-source"));
  int packages_written = 0;

  if (!empty_string_p (filename))
    {
      int fd = os_open (filename, O_WRONLY | O_TRUNC | O_CREAT, 0666);

      if (fd > -1)
	{
	  register int i = 1;
	  char *arg;

	  while ((arg = get_positional_arg (vars, i)) != (char *)NULL)
	    {
	      char *packname = mhtml_evaluate_string (arg);

	      if (!empty_string_p (packname))
		{
		  Package *pack = symbol_lookup_package (packname);

		  if (pack != (Package *)NULL)
		    {
		      symbol_dump_package (fd, pack,
					   !empty_string_p (flagged),
					   !empty_string_p (no_source));
		      packages_written++;
		    }
		}

	      if (packname) free (packname);
	      i++;
	    }
	  close (fd);
	}
    }

  xfree (filename);
  xfree (flagged);
  xfree (no_source);

  if (packages_written)
    bprintf_insert (page, start, "%d", packages_written);
}
开发者ID:AOSC-Dev,项目名称:metahtml,代码行数:48,代码来源:prims.c



注:本文中的os_open函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ os_printf函数代码示例发布时间:2022-05-30
下一篇:
C++ os_mutexUnlock函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap