Beispiel #1
0
HRESULT SHELL32_ParseNextElement (IShellFolder2 * psf, HWND hwndOwner, LPBC pbc,
				  LPITEMIDLIST * pidlInOut, LPOLESTR szNext, DWORD * pEaten, DWORD * pdwAttributes)
{
    LPITEMIDLIST pidlOut = NULL, pidlTemp = NULL;
    IShellFolder *psfChild;
    HRESULT hr;

    TRACE ("(%p, %p, %p, %s)\n", psf, pbc, pidlInOut ? *pidlInOut : NULL, debugstr_w (szNext));

    /* get the shellfolder for the child pidl and let it analyse further */
    hr = IShellFolder2_BindToObject (psf, *pidlInOut, pbc, &IID_IShellFolder, (LPVOID *) & psfChild);

    if (SUCCEEDED(hr)) {
	hr = IShellFolder_ParseDisplayName (psfChild, hwndOwner, pbc, szNext, pEaten, &pidlOut, pdwAttributes);
	IShellFolder_Release (psfChild);

	if (SUCCEEDED(hr)) {
	    pidlTemp = ILCombine (*pidlInOut, pidlOut);

	    if (!pidlTemp)
		hr = E_OUTOFMEMORY;
	}

	if (pidlOut)
	    ILFree (pidlOut);
    }

    ILFree (*pidlInOut);
    *pidlInOut = pidlTemp;

    TRACE ("-- pidl=%p ret=0x%08x\n", pidlInOut ? *pidlInOut : NULL, hr);
    return hr;
}
Beispiel #2
0
/*
 * Make a directory.
 */
static int Task_Mkdir(CSAntTask *task)
{
	const char *dirParam = CSAntTaskParam(task, "dir");
	char *dir;
	int retval;
	if(!dirParam)
	{
		fprintf(stderr, "no directory to make in <mkdir>\n");
		return 0;
	}
	dir = CSAntDirCombine(CSAntBaseBuildDir, dirParam);
	if(!CSAntSilent)
	{
		printf("mkdir -p %s\n", dir);
	}
	retval = Mkdir_P(CSAntBaseBuildDir, dirParam);
	if(retval != IL_ERRNO_Success)
	{
		ILSysIOSetErrno(retval);
		perror(dir);
		ILFree(dir);
		return 0;
	}
	ILFree(dir);
	return 1;
}
Beispiel #3
0
ILDir *ILOpenDir(const char *path)
{
	char *spec;
	int len;
	ILDir *dir = (ILDir *)ILMalloc(sizeof(ILDir));
	if(!dir)
	{
		return 0;
	}
	spec = (char *)ILMalloc(strlen(path) + 5);
	if(!spec)
	{
		ILFree(dir);
		return 0;
	}
	strcpy(spec, path);
	len = strlen(spec);
	if(len > 0 && spec[len - 1] != '/' && spec[len - 1] != '\\')
	{
		spec[len++] = '\\';
	}
	strcpy(spec + len, "*.*");
	dir->handle = _findfirst(spec, &(dir->fileinfo));
	dir->havefirst = 1;
	if(dir->handle < 0)
	{
		int error = errno;
		ILFree(dir);
		ILFree(spec);
		errno = error;
		return 0;
	}
	ILFree(spec);
	return dir;
}
Beispiel #4
0
void *ILDynLibraryGetSymbol(void *handle, const char *symbol)
{
	void *value = GetSymbol(handle, (char *)symbol);
	char *newName;
	if(value)
	{
		return value;
	}
	newName = (char *)ILMalloc(strlen(symbol) + 2);
	if(newName)
	{
		/* Try again with '_' prepended to the name */
		newName[0] = '_';
		strcpy(newName + 1, symbol);
		value = GetSymbol(handle, newName);
		if(value)
		{
			ILFree(newName);
			return value;
		}
		ILFree(newName);
	}
#ifdef IL_DYNLIB_DEBUG
	fprintf(stderr, "%s: could not find the specified symbol\n", symbol);
#endif
	return 0;
}
Beispiel #5
0
void *ILDynLibraryGetSymbol(void *handle, const char *symbol)
{
	void *value = dlsym(handle, (char *)symbol);
	const char *error = dlerror();
	char *newName;
	if(error == 0)
	{
		return value;
	}
	newName = (char *)ILMalloc(strlen(symbol) + 2);
	if(newName)
	{
		/* Try again with '_' prepended to the name in case
		   we are running on a system with a busted "dlsym" */
		newName[0] = '_';
		strcpy(newName + 1, symbol);
		value = dlsym(handle, newName);
		error = dlerror();
		if(error == 0)
		{
			ILFree(newName);
			return value;
		}
		ILFree(newName);
	}
#ifdef IL_DYNLIB_DEBUG
	fprintf(stderr, "%s: %s\n", symbol, error);
#endif
	return 0;
}
Beispiel #6
0
/*
 * Implementing this way because opendir seems to be somewhat non-standardised.
 * so basically I think this way will be a lot more portable.
 */
ILDir *ILOpenDir(const char *path)
{
#ifdef HAVE_DIRENT_H
	ILDir *dir = (ILDir *)ILMalloc(sizeof(ILDir));
	if(dir)
	{
		dir->pathname = ILDupString(path);
		if(!(dir->pathname))
		{
			ILFree(dir);
			return (ILDir *)0;
		}
		dir->dir = opendir(dir->pathname);
		if(!(dir->dir))
		{
			ILFree(dir->pathname);
			ILFree(dir);
			return (ILDir *)0;
		}
	}
	return dir;
#else
	errno = ENOENT;
	return (ILDir *)0;
#endif
}
Beispiel #7
0
static CName ILNode_CName_83__(ILNode_Conditional *node)
#line 505 "c_name.tc"
{
	CName name1 = ILNode_CName(node->expr1);
	CName name2 = ILNode_CName(node->expr2);
	CName name3 = ILNode_CName(node->expr3);
	CName result;
	result.name = (char *)ILMalloc(strlen(name1.name) + strlen(name2.name) +
								   strlen(name3.name) + 15);
	if(!(result.name))
	{
		CCOutOfMemory();
	}
	strcpy(result.name, "((");
	strcat(result.name, name1.name);
	strcat(result.name, ") ? (");
	strcat(result.name, name2.name);
	strcat(result.name, ") : (");
	strcat(result.name, name3.name);
	strcat(result.name, "))");
	ILFree(name1.name);
	ILFree(name2.name);
	ILFree(name3.name);
	result.prec = C_PREC_PRIMARY;
	return result;
}
Beispiel #8
0
static void ILArrayListDestroy(ILList *_list)
{
	ILArrayList *list = (ILArrayList *)_list;

	ILFree(list->array);
	ILFree(list);
}
void ILSerializeWriterDestroy(ILSerializeWriter *writer)
{
	if(writer->blob)
	{
		ILFree(writer->blob);
	}
	ILFree(writer);
}
Beispiel #10
0
/* Tests for My Network Places */
static void test_parse_for_entire_network(void)
{
    static WCHAR my_network_places_path[] = {
        ':',':','{','2','0','8','D','2','C','6','0','-','3','A','E','A','-',
                    '1','0','6','9','-','A','2','D','7','-','0','8','0','0','2','B','3','0','3','0','9','D','}', 0 };
    static WCHAR entire_network_path[] = {
        ':',':','{','2','0','8','D','2','C','6','0','-','3','A','E','A','-',
                    '1','0','6','9','-','A','2','D','7','-','0','8','0','0','2','B','3','0','3','0','9','D',
                '}','\\','E','n','t','i','r','e','N','e','t','w','o','r','k',0 };
    IShellFolder *psfDesktop;
    HRESULT hr;
    DWORD eaten = 0xdeadbeef;
    LPITEMIDLIST pidl;
    DWORD attr = ~0;
    DWORD expected_attr;

    hr = SHGetDesktopFolder(&psfDesktop);
    ok(hr == S_OK, "SHGetDesktopFolder failed with error 0x%x\n", hr);

    hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, my_network_places_path, &eaten, &pidl, &attr);
    ok(hr == S_OK, "IShellFolder_ParseDisplayName failed with error 0x%x\n", hr);
    todo_wine
    ok(eaten == 0xdeadbeef, "eaten should not have been set to %u\n", eaten);
    expected_attr = SFGAO_HASSUBFOLDER|SFGAO_FOLDER|SFGAO_FILESYSANCESTOR|SFGAO_DROPTARGET|SFGAO_HASPROPSHEET|SFGAO_CANRENAME|SFGAO_CANLINK;
    todo_wine
    ok((attr == expected_attr) || /* Win9x, NT4 */
       (attr == (expected_attr | SFGAO_STREAM)) || /* W2K */
       (attr == (expected_attr | SFGAO_CANDELETE)) || /* XP, W2K3 */
       (attr == (expected_attr | SFGAO_CANDELETE | SFGAO_NONENUMERATED)), /* Vista */
       "Unexpected attributes : %08x\n", attr);

    ILFree(pidl);

    /* Start clean again */
    eaten = 0xdeadbeef;
    attr = ~0;

    hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, entire_network_path, &eaten, &pidl, &attr);
    IShellFolder_Release(psfDesktop);
    if (hr == HRESULT_FROM_WIN32(ERROR_BAD_NET_NAME) ||
        hr == HRESULT_FROM_WIN32(ERROR_NO_NET_OR_BAD_PATH) ||
        hr == HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER))
    {
        win_skip("'EntireNetwork' is not available on Win9x, NT4 and Vista\n");
        return;
    }
    ok(hr == S_OK, "IShellFolder_ParseDisplayName failed with error 0x%x\n", hr);
    todo_wine
    ok(eaten == 0xdeadbeef, "eaten should not have been set to %u\n", eaten);
    expected_attr = SFGAO_HASSUBFOLDER|SFGAO_FOLDER|SFGAO_FILESYSANCESTOR|SFGAO_HASPROPSHEET|SFGAO_CANLINK;
    todo_wine
    ok(attr == expected_attr || /* winme, nt4 */
       attr == (expected_attr | SFGAO_STREAM) || /* win2k */
       attr == (expected_attr | SFGAO_STORAGEANCESTOR),  /* others */
       "attr should be 0x%x, not 0x%x\n", expected_attr, attr);

    ILFree(pidl);
}
Beispiel #11
0
/*  This function will return NULL on error  */
ILDirEnt *ILReadDir(ILDir *directory)
{
#ifdef HAVE_DIRENT_H
    
#if defined(HAVE_READDIR_R) && !defined(BROKEN_DIRENT)
	ILDirEnt *result = NULL;

	/* Threadsafe version of readdir() */
	/*  Fetch a directory entry  */
	if((result = (ILDirEnt *)ILMalloc(sizeof(ILDirEnt))) == NULL)
    {
        return NULL;
    }
    
	if(readdir_r(directory->dir, &(result->de), &(result->dptr)) != 0)
	{
		ILFree(result);
		return NULL;
	}
	if(!(result->dptr)) /* yet another terminating condition */
	{
		ILFree(result);
		return NULL;
	}

	GetDirEntryType(directory, result);
	return result;
#else
#ifdef HAVE_READDIR
	/*  Not Threadsafe, so maybe if systems need it, we should rewrite it.  */
	struct dirent *result;
	ILDirEnt *allocatedResult = NULL;
	if((result = readdir(directory->dir)) == NULL)
	{
		return NULL;
	}

	/*  After we know we HAVE a result, we copy it's contents into our 
	 * 	own struct  */
	allocatedResult = (ILDirEnt *)ILMalloc(sizeof(ILDirEnt));
	if(allocatedResult != NULL)
	{
		allocatedResult->dptr = &(allocatedResult->de);
		ILMemCpy(&(allocatedResult->de), result, sizeof(struct dirent));
#if defined(BROKEN_DIRENT)
		strcpy(allocatedResult->de.d_name, result->d_name);
#endif
		GetDirEntryType(directory, allocatedResult);
	}
	return allocatedResult;
#else
	return NULL;
#endif
#endif
#else
	return NULL;
#endif
}
Beispiel #12
0
HRESULT WINAPI SHCreateShellItem(LPCITEMIDLIST pidlParent,
    IShellFolder *psfParent, LPCITEMIDLIST pidl, IShellItem **ppsi)
{
    LPITEMIDLIST new_pidl;
    HRESULT ret;

    TRACE("(%p,%p,%p,%p)\n", pidlParent, psfParent, pidl, ppsi);

    *ppsi = NULL;

    if (!pidl)
    {
        return E_INVALIDARG;
    }
    else if (pidlParent || psfParent)
    {
        LPITEMIDLIST temp_parent=NULL;
        if (!pidlParent)
        {
            IPersistFolder2* ppf2Parent;

            if (FAILED(IShellFolder_QueryInterface(psfParent, &IID_IPersistFolder2, (void**)&ppf2Parent)))
            {
                FIXME("couldn't get IPersistFolder2 interface of parent\n");
                return E_NOINTERFACE;
            }

            if (FAILED(IPersistFolder2_GetCurFolder(ppf2Parent, &temp_parent)))
            {
                FIXME("couldn't get parent PIDL\n");
                IPersistFolder2_Release(ppf2Parent);
                return E_NOINTERFACE;
            }

            pidlParent = temp_parent;
            IPersistFolder2_Release(ppf2Parent);
        }

        new_pidl = ILCombine(pidlParent, pidl);
        ILFree(temp_parent);

        if (!new_pidl)
            return E_OUTOFMEMORY;
    }
    else
    {
        new_pidl = ILClone(pidl);
        if (!new_pidl)
            return E_OUTOFMEMORY;
    }

    ret = SHCreateItemFromIDList(new_pidl, &IID_IShellItem, (void**)ppsi);
    ILFree(new_pidl);

    return ret;
}
Beispiel #13
0
/*
 * Destroy a parameter.
 */
static void DestroyParameter(ILDocParameter *parameter)
{
	if(parameter->name)
	{
		ILFree(parameter->name);
	}
	if(parameter->type)
	{
		ILFree(parameter->type);
	}
}
Beispiel #14
0
int ILCloseDir(ILDir *directory)
{
#ifdef HAVE_DIRENT_H
	int result = (closedir(directory->dir) == 0);
	ILFree(directory->pathname);
	ILFree(directory);
	return result;
#else
	return 0;
#endif
}
Beispiel #15
0
void CreateLnkOnDesktop(const LPWSTR connTitle)
{
	IShellLink   *SLink;
	IPersistFile *PF;
	HRESULT HRes;
	TCHAR desktop_path[MAX_PATH] = TEXT("");
	TCHAR pszFullLnkPath[MAX_PATH]; 

	CoInitialize(NULL);

	ITEMIDLIST* pidl1 = NULL;
    SHGetFolderLocation(NULL, CSIDL_CONNECTIONS, NULL, 0, &pidl1);
    IShellFolder *desktop, *ncfolder;
    SHGetDesktopFolder(&desktop);
    desktop->BindToObject(pidl1, NULL, IID_IShellFolder, (void**)&ncfolder);

    IEnumIDList *items;
    ncfolder->EnumObjects(NULL, SHCONTF_NONFOLDERS, &items);
    ITEMIDLIST* pidl2 = NULL;
    while (S_OK == items->Next(1, &pidl2, NULL))
    {
        STRRET sr = {STRRET_WSTR};
        ncfolder->GetDisplayNameOf(pidl2, SHGDN_NORMAL, &sr);

        TCHAR buf[MAX_PATH] = TEXT("");
        StrRetToBuf(&sr, pidl2, buf, MAX_PATH);

        if (0 == StrCmpI(buf, connTitle))
        {
            ITEMIDLIST* pidl3 = ILCombine(pidl1, pidl2);
			HRESULT HRes = CoCreateInstance(CLSID_ShellLink, 0, CLSCTX_INPROC_SERVER, IID_IShellLink, ( LPVOID*)&SLink);
            SLink->SetIDList(pidl3);
			SHGetFolderPath(NULL, CSIDL_DESKTOP, NULL, 0, desktop_path);
			StringCbPrintf(pszFullLnkPath, MAX_PATH * sizeof(TCHAR), TEXT("%s\\%s.lnk"), desktop_path, connTitle);
			HRes = SLink->QueryInterface(IID_IPersistFile, (LPVOID*)&PF);
			HRes = PF->Save((LPCOLESTR)pszFullLnkPath, TRUE);
			PF->Release();
			SLink->Release();
            ILFree(pidl3);
            ILFree(pidl2);
            break;
        }

        ILFree(pidl2);
        pidl2 = NULL;
    }
	ncfolder->Release();
	desktop->Release();

    ILFree(pidl1);

	CoUninitialize();
}
Beispiel #16
0
/* Tests for Control Panel */
static void test_parse_for_control_panel(void)
{
    /* path of My Computer\Control Panel */
    static WCHAR control_panel_path[] = {
        ':',':','{','2','0','D','0','4','F','E','0','-','3','A','E','A','-','1','0','6','9','-','A','2','D','8','-','0','8','0','0','2','B','3','0','3','0','9','D','}','\\',
        ':',':','{','2','1','E','C','2','0','2','0','-','3','A','E','A','-','1','0','6','9','-','A','2','D','D','-','0','8','0','0','2','B','3','0','3','0','9','D','}', 0 };
    IShellFolder *psfDesktop;
    HRESULT hr;
    DWORD eaten = 0xdeadbeef;
    LPITEMIDLIST pidl;
    DWORD attr = ~0;

    hr = SHGetDesktopFolder(&psfDesktop);
    ok(hr == S_OK, "SHGetDesktopFolder failed with error 0x%x\n", hr);

    hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, control_panel_path, &eaten, &pidl, &attr);
    ok(hr == S_OK, "IShellFolder_ParseDisplayName failed with error 0x%x\n", hr);
    todo_wine ok(eaten == 0xdeadbeef, "eaten should not have been set to %u\n", eaten);
    todo_wine
    ok((attr == (SFGAO_CANLINK | SFGAO_FOLDER)) || /* Win9x, NT4 */
       (attr == (SFGAO_CANLINK | SFGAO_FOLDER | SFGAO_HASSUBFOLDER | SFGAO_STREAM)) || /* W2K */
       (attr == (SFGAO_CANLINK | SFGAO_FOLDER | SFGAO_HASSUBFOLDER)) || /* W2K, XP, W2K3 */
       (attr == (SFGAO_CANLINK | SFGAO_NONENUMERATED)) || /* Vista */
       (attr == SFGAO_CANLINK), /* Vista, W2K8 */
       "Unexpected attributes : %08x\n", attr);

    ILFree(pidl);
}
Beispiel #17
0
/*
 * Make a directory, and all parent directories.
 */
static int Mkdir_P(const char *base, const char *dir)
{
      char *path = CSAntDirCombine(base, dir);
      char* slashpos = &path[strlen(base)];
      char* bslashpos;
      int retval = 0;
      char save;

      if(!path)
      {
		return errno;
      }
      while(*slashpos != '\0')
      {
		bslashpos = strchr(slashpos + 1, '\\');
		slashpos = strchr(slashpos + 1, '/');
		if (slashpos == 0 || (bslashpos != 0 && slashpos > bslashpos))
		  	slashpos = bslashpos;
		if (slashpos == 0)
		  	slashpos = strchr(path, '\0');
		save = *slashpos;
		*slashpos = '\0';
		retval = ILCreateDir(path);
		*slashpos = save;
		if (retval != IL_ERRNO_Success && retval != IL_ERRNO_EEXIST)
		  	break;
      }
      if(retval == IL_ERRNO_EEXIST)
		retval = IL_ERRNO_Success;
      ILFree(path);
      return retval;
}
Beispiel #18
0
/***********************************************************************
 *    SHELL32_CoCreateInitSF
 *
 * Creates a shell folder and initializes it with a pidl and a root folder
 * via IPersistFolder3 or IPersistFolder.
 *
 * NOTES
 *   pathRoot can be NULL for Folders being a drive.
 *   In this case the absolute path is built from pidlChild (eg. C:)
 */
HRESULT SHELL32_CoCreateInitSF (LPCITEMIDLIST pidlRoot, PERSIST_FOLDER_TARGET_INFO* ppfti,
                LPCITEMIDLIST pidlChild, const GUID* clsid, REFIID riid, LPVOID *ppvOut)
{
    HRESULT hr;
    CComPtr<IShellFolder> pShellFolder;

    hr = SHCoCreateInstance(NULL, clsid, NULL, IID_PPV_ARG(IShellFolder, &pShellFolder));
    if (FAILED(hr))
        return hr;

    LPITEMIDLIST pidlAbsolute = ILCombine (pidlRoot, pidlChild);
    CComPtr<IPersistFolder> ppf;
    CComPtr<IPersistFolder3> ppf3;

    if (ppfti && SUCCEEDED(pShellFolder->QueryInterface(IID_PPV_ARG(IPersistFolder3, &ppf3))))
    {
        ppf3->InitializeEx(NULL, pidlAbsolute, ppfti);
    }
    else if (SUCCEEDED(pShellFolder->QueryInterface(IID_PPV_ARG(IPersistFolder, &ppf))))
    {
        ppf->Initialize(pidlAbsolute);
    }
    ILFree (pidlAbsolute);

    return pShellFolder->QueryInterface(riid, ppvOut);
}
int ILGenImplementsAllInterfaces(ILGenInfo *info, ILNode *node,
                                 ILClass *classInfo,
                                 ILGenInterfaceErrorFunc error,
                                 ILGenInterfaceProxyFunc proxy)
{
    ILClass **visited;
    int visitedSize;
    int sawErrors;

    /* Allocate a temporary array to keep track of which interfaces
       we have already visited, in case the same interface is present
       along multiple inheritance paths */
    visited = (ILClass **)ILMalloc(sizeof(ILClass *) *
                                   GetSpanningSize(classInfo));
    if(!visited)
    {
        ILGenOutOfMemory(info);
    }
    visitedSize = 0;

    /* Recursively visit all interfaces */
    sawErrors = ImplementsAllInterfaces(node, classInfo, classInfo, error,
                                        proxy, visited, &visitedSize);

    /* Clean up and exit */
    ILFree(visited);
    return !sawErrors;
}
Beispiel #20
0
/*************************************************************************
 * SHBrowseForFolderW [[email protected]]
 *
 * NOTES
 *  crashes when passed a null pointer
 */
LPITEMIDLIST WINAPI SHBrowseForFolderW (LPBROWSEINFOW lpbi)
{
    browse_info info;
    DWORD r;
    HRESULT hr;
    const WCHAR * templateName;

    info.hWnd = 0;
    info.pidlRet = NULL;
    info.lpBrowseInfo = lpbi;
    info.hwndTreeView = NULL;

    hr = OleInitialize(NULL);

    if (lpbi->ulFlags & BIF_NEWDIALOGSTYLE)
        templateName = swNewBrowseTemplateName;
    else
        templateName = swBrowseTemplateName;
    r = DialogBoxParamW( shell32_hInstance, templateName, lpbi->hwndOwner,
	                 BrsFolderDlgProc, (LPARAM)&info );
    if (SUCCEEDED(hr)) 
        OleUninitialize();
    if (!r)
    {
        ILFree(info.pidlRet);
        return NULL;
    }

    return info.pidlRet;
}
Beispiel #21
0
CName CNameCreateUnary(const char *oper, CName arg, int prec)
{
	CName result;
	result.name = (char *)ILMalloc(strlen(oper) + strlen(arg.name) + 4);
	if(!(result.name))
	{
		CCOutOfMemory();
	}
	if(prec > arg.prec)
	{
		strcpy(result.name, oper);
		strcat(result.name, " (");
		strcat(result.name, arg.name);
		strcat(result.name, ")");
	}
	else
	{
		strcpy(result.name, oper);
		strcat(result.name, " ");
		strcat(result.name, arg.name);
	}
	ILFree(arg.name);
	result.prec = prec;
	return result;
}
Beispiel #22
0
/***********************************************************************
 *	SHELL32_GetDisplayNameOfChild
 *
 * Retrieves the display name of a child object of a shellfolder.
 *
 * For a pidl eg. [subpidl1][subpidl2][subpidl3]:
 * - it binds to the child shellfolder [subpidl1]
 * - asks it for the displayname of [subpidl2][subpidl3]
 *
 * Is possible the pidl is a simple pidl. In this case it asks the
 * subfolder for the displayname of an empty pidl. The subfolder
 * returns the own displayname eg. "::{guid}". This is used for
 * virtual folders with the registry key WantsFORPARSING set.
 */
HRESULT SHELL32_GetDisplayNameOfChild (IShellFolder2 * psf,
				       LPCITEMIDLIST pidl, DWORD dwFlags, LPWSTR szOut, DWORD dwOutLen)
{
    LPITEMIDLIST pidlFirst;
    HRESULT hr;

    TRACE ("(%p)->(pidl=%p 0x%08x %p 0x%08x)\n", psf, pidl, dwFlags, szOut, dwOutLen);
    pdump (pidl);

    pidlFirst = ILCloneFirst (pidl);
    if (pidlFirst) {
	IShellFolder2 *psfChild;

	hr = IShellFolder2_BindToObject (psf, pidlFirst, NULL, &IID_IShellFolder, (LPVOID *) & psfChild);
	if (SUCCEEDED (hr)) {
	    STRRET strTemp;
	    LPITEMIDLIST pidlNext = ILGetNext (pidl);

	    hr = IShellFolder2_GetDisplayNameOf (psfChild, pidlNext, dwFlags, &strTemp);
	    if (SUCCEEDED (hr)) {
		if(!StrRetToStrNW (szOut, dwOutLen, &strTemp, pidlNext))
                    hr = E_FAIL;
	    }
	    IShellFolder2_Release (psfChild);
	}
	ILFree (pidlFirst);
    } else
	hr = E_OUTOFMEMORY;

    TRACE ("-- ret=0x%08x %s\n", hr, debugstr_w(szOut));

    return hr;
}
Beispiel #23
0
/*
 * Destroy an interface.
 */
static void DestroyInterface(ILDocInterface *interface)
{
	if(interface->name)
	{
		ILFree(interface->name);
	}
}
Beispiel #24
0
/*
 * Process a "/recurse" option.
 */
static void recurseOption(char *arg)
{
	char * dirPrefix = NULL;
	int i=0;
	if((arg==NULL) || (arg[0])=='\0')
	{
		return;
	}

	dirPrefix = ILCalloc(strlen(arg)+1,sizeof(char));

	while(((*arg)!='\0') && ((*arg)!='*'))
	{
		dirPrefix[i++]=*arg;
		arg++;
	}

	if(*dirPrefix == '\0')
	{
		// /recurse:*.cs starts from current dir
		dirPrefix[0]='.';
	}

	recurseAndAddFiles(dirPrefix,arg);

//cleanup:
	if(dirPrefix)
	{
		ILFree(dirPrefix);
	}
}
/*
 * public static String GetGlobalConfigDir();
 */
extern ILString *_IL_InfoMethods_GetGlobalConfigDir(ILExecThread *_thread)
{
#if !defined(__palmos__)
	char *env;
	ILString *str;

	/* Try the "CLI_MACHINE_CONFIG_DIR" environment variable first */
	if((env = getenv("CLI_MACHINE_CONFIG_DIR")) != 0 && *env != '\0')
	{
		return ILStringCreate(_thread, env);
	}

	/* Return a standard path such as "/usr/local/share/cscc/config" */
	env = ILGetStandardDataPath("cscc/config");
	if(!env)
	{
		ILExecThreadThrowOutOfMemory(_thread);
		return 0;
	}
	str = ILStringCreate(_thread, env);
	ILFree(env);
	return str;
#else
	return 0;
#endif
}
Beispiel #26
0
/*************************************************************************
 * SHBrowseForFolderW [[email protected]]
 *
 * NOTES
 *  crashes when passed a null pointer
 */
LPITEMIDLIST WINAPI SHBrowseForFolderW (LPBROWSEINFOW lpbi)
{
    browse_info info;
    DWORD r;
    HRESULT hr;
    const WCHAR * templateName;
    INITCOMMONCONTROLSEX icex;

    info.hWnd = 0;
    info.pidlRet = NULL;
    info.lpBrowseInfo = lpbi;
    info.hwndTreeView = NULL;

    icex.dwSize = sizeof( icex );
    icex.dwICC = ICC_TREEVIEW_CLASSES;
    InitCommonControlsEx( &icex );

    hr = OleInitialize(NULL);

    if (lpbi->ulFlags & BIF_NEWDIALOGSTYLE)
        templateName = swNewBrowseTemplateName;
    else
        templateName = swBrowseTemplateName;
    r = DialogBoxParamW( shell32_hInstance, templateName, lpbi->hwndOwner,
	                 BrsFolderDlgProc, (LPARAM)&info );
    if (SUCCEEDED(hr)) 
        OleUninitialize();
    if (!r)
    {
        ILFree(info.pidlRet);
        return NULL;
    }

    return info.pidlRet;
}
Beispiel #27
0
/*
 * Destroy an attribute.
 */
static void DestroyAttribute(ILDocAttribute *attribute)
{
	if(attribute->name)
	{
		ILFree(attribute->name);
	}
}
Beispiel #28
0
static HRESULT ShellItem_get_parent_shellfolder(ShellItem *This, IShellFolder **ppsf)
{
    LPITEMIDLIST parent_pidl;
    IShellFolder *desktop;
    HRESULT ret;

    ret = ShellItem_get_parent_pidl(This, &parent_pidl);
    if (SUCCEEDED(ret))
    {
        ret = SHGetDesktopFolder(&desktop);
        if (SUCCEEDED(ret))
        {
            if (_ILIsDesktop(parent_pidl))
            {
                *ppsf = desktop;
            }
            else
            {
                ret = IShellFolder_BindToObject(desktop, parent_pidl, NULL, &IID_IShellFolder, (void**)ppsf);
                IShellFolder_Release(desktop);
            }
        }
        ILFree(parent_pidl);
    }

    return ret;
}
bool getOpenDirectory(char* out, int max_size, const char* starting_dir)
{
	bool ret = false;
	IFileDialog* pfd;
	if (SUCCEEDED(CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pfd))))
	{
		if (starting_dir)
		{
			PIDLIST_ABSOLUTE pidl;
			WCHAR wstarting_dir[MAX_PATH];
			WCHAR* wc = wstarting_dir;
			for (const char *c = starting_dir; *c && wc - wstarting_dir < MAX_PATH - 1; ++c, ++wc)
			{
				*wc = *c == '/' ? '\\' : *c;
			}
			*wc = 0;

			HRESULT hresult = ::SHParseDisplayName(wstarting_dir, 0, &pidl, SFGAO_FOLDER, 0);
			if (SUCCEEDED(hresult))
			{
				IShellItem* psi;
				hresult = ::SHCreateShellItem(NULL, NULL, pidl, &psi);
				if (SUCCEEDED(hresult))
				{
					pfd->SetFolder(psi);
				}
				ILFree(pidl);
			}
		}

		DWORD dwOptions;
		if (SUCCEEDED(pfd->GetOptions(&dwOptions)))
		{
			pfd->SetOptions(dwOptions | FOS_PICKFOLDERS);
		}
		if (SUCCEEDED(pfd->Show(NULL)))
		{
			IShellItem* psi;
			if (SUCCEEDED(pfd->GetResult(&psi)))
			{
				WCHAR* tmp;
				if (SUCCEEDED(psi->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, &tmp)))
				{
					char* c = out;
					while (*tmp && c - out < max_size - 1)
					{
						*c = (char)*tmp;
						++c;
						++tmp;
					}
					*c = '\0';
					ret = true;
				}
				psi->Release();
			}
		}
		pfd->Release();
	}
	return ret;
}
Beispiel #30
0
static void update_shell_folder_listview(HWND dialog) {
    int i;
    LVITEMW item;
    LONG lSelected = SendDlgItemMessageW(dialog, IDC_LIST_SFPATHS, LVM_GETNEXTITEM, -1,
                                        MAKELPARAM(LVNI_SELECTED,0));

    SendDlgItemMessageW(dialog, IDC_LIST_SFPATHS, LVM_DELETEALLITEMS, 0, 0);

    for (i=0; i<NUM_ELEMS(asfiInfo); i++) {
        WCHAR buffer[MAX_PATH];
        HRESULT hr;
        LPITEMIDLIST pidlCurrent;

        /* Some acrobatic to get the localized name of the shell folder */
        hr = SHGetFolderLocation(dialog, asfiInfo[i].nFolder, NULL, 0, &pidlCurrent);
        if (SUCCEEDED(hr)) { 
            LPSHELLFOLDER psfParent;
            LPCITEMIDLIST pidlLast;
            hr = SHBindToParent(pidlCurrent, &IID_IShellFolder, (LPVOID*)&psfParent, &pidlLast);
            if (SUCCEEDED(hr)) {
                STRRET strRet;
                hr = IShellFolder_GetDisplayNameOf(psfParent, pidlLast, SHGDN_FORADDRESSBAR, &strRet);
                if (SUCCEEDED(hr)) {
                    hr = StrRetToBufW(&strRet, pidlLast, buffer, MAX_PATH);
                }
                IShellFolder_Release(psfParent);
            }
            ILFree(pidlCurrent);
        }

        /* If there's a dangling symlink for the current shell folder, SHGetFolderLocation
         * will fail above. We fall back to the (non-verified) path of the shell folder. */
        if (FAILED(hr)) {
            hr = SHGetFolderPathW(dialog, asfiInfo[i].nFolder|CSIDL_FLAG_DONT_VERIFY, NULL,
                                 SHGFP_TYPE_CURRENT, buffer);
        }
    
        item.mask = LVIF_TEXT | LVIF_PARAM;
        item.iItem = i;
        item.iSubItem = 0;
        item.pszText = buffer;
        item.lParam = (LPARAM)&asfiInfo[i];
        SendDlgItemMessageW(dialog, IDC_LIST_SFPATHS, LVM_INSERTITEMW, 0, (LPARAM)&item);

        item.mask = LVIF_TEXT;
        item.iItem = i;
        item.iSubItem = 1;
        item.pszText = strdupU2W(asfiInfo[i].szLinkTarget);
        SendDlgItemMessageW(dialog, IDC_LIST_SFPATHS, LVM_SETITEMW, 0, (LPARAM)&item);
        HeapFree(GetProcessHeap(), 0, item.pszText);
    }

    /* Ensure that the previously selected item is selected again. */
    if (lSelected >= 0) {
        item.mask = LVIF_STATE;
        item.state = LVIS_SELECTED;
        item.stateMask = LVIS_SELECTED;
        SendDlgItemMessageW(dialog, IDC_LIST_SFPATHS, LVM_SETITEMSTATE, lSelected, (LPARAM)&item);
    }
}