Esempio n. 1
0
static void
makedirs (char const *name)
{
  char *filename = xstrdup (name);
  char *f;
  char *flim = replace_slashes (filename);

  if (flim)
    {
      /* Create any missing directories, replacing NULs by '/'s.
	 Ignore errors.  We may have to keep going even after an EEXIST,
	 since the path may contain ".."s; and when there is an EEXIST
	 failure the system may return some other error number.
	 Any problems will eventually be reported when we create the file.  */
      for (f = filename;  f <= flim;  f++)
	if (!*f)
	  {
	    mkdir (filename,
		   S_IRUSR|S_IWUSR|S_IXUSR
		   |S_IRGRP|S_IWGRP|S_IXGRP
		   |S_IROTH|S_IWOTH|S_IXOTH);
	    *f = '/';
	  }
    }
  free (filename);
}
Esempio n. 2
0
LPITEMIDLIST sh_getpidl (IShellFolder *pSF, const char *path)
{
	HRESULT hr; WCHAR wpath[MAX_PATH]; ULONG chEaten;
	LPITEMIDLIST pIDFolder;

	if (NULL == pSF)
	{
		hr = SHGetDesktopFolder(&pSF);
		if (NOERROR!=hr)
			return NULL;
	}

	char temp[MAX_PATH];
	replace_slashes(temp, path);

	MultiByteToWideChar(CP_ACP, 0, temp, -1, wpath, MAX_PATH);
	hr = pSF->ParseDisplayName(
		NULL, NULL, wpath, &chEaten, &pIDFolder, NULL);

	pSF->Release();
	if (NOERROR!=hr)
		return NULL;

	LPITEMIDLIST pID = duplicateIDlist(pIDFolder);
	SHMalloc_Free(pIDFolder);

	return pID;
}
Esempio n. 3
0
File: conf.c Progetto: idtek/knot
static int str_zone(
	const knot_dname_t *zone,
	char *buff,
	size_t buff_len)
{
	if (knot_dname_to_str(buff, zone, buff_len) == NULL) {
		return KNOT_EINVAL;
	}

	// Replace possible slashes with underscores.
	replace_slashes(buff, true);

	return KNOT_EOK;
}
Esempio n. 4
0
File: conf.c Progetto: idtek/knot
static int str_char(
	const knot_dname_t *zone,
	char *buff,
	size_t buff_len,
	uint8_t index1,
	uint8_t index2)
{
	if (knot_dname_to_str(buff, zone, buff_len) == NULL) {
		return KNOT_EINVAL;
	}

	// Remove the trailing dot.
	size_t zone_len = strlen(buff);
	assert(zone_len > 0);
	buff[zone_len--] = '\0';

	// Get the block length.
	size_t len = index2 - index1 + 1;

	// Check for out of scope block.
	if (index1 >= zone_len) {
		buff[0] = '\0';
		return KNOT_EOK;
	}
	// Check for partial block.
	if (index2 >= zone_len) {
		len = zone_len - index1;
	}

	// Copy the block.
	memmove(buff, buff + index1, len);
	buff[len] = '\0';

	// Replace possible slashes with underscores.
	replace_slashes(buff, false);

	return KNOT_EOK;
}