/// <summary> /// Returns a list of source controllable files associated with the specified node /// </summary> private static IList <string> GetNodeFiles(IVsSccProject2 pscp2, uint itemid) { // NOTE: the function returns only a list of files, containing both regular files and special files // If you want to hide the special files (similar with solution explorer), you may need to return // the special files in a hastable (key=master_file, values=special_file_list) // Initialize output parameters IList <string> sccFiles = new List <string>(); if (pscp2 != null) { CALPOLESTR[] pathStr = new CALPOLESTR[1]; CADWORD[] flags = new CADWORD[1]; if (pscp2.GetSccFiles(itemid, pathStr, flags) == 0) { //#4 BugFix : Visual Studio Crashing when clicking on Web Reference // The previus MS sample code used 'Marshal.PtrToStringAuto' which caused // a chrash of the studio (2010 only) in some conditions. This also could // be the reason for some further bugs e.g. in commit, update tasks. string[] files = GetFileNamesFromOleBuffer(pathStr, true); for (int elemIndex = 0; elemIndex < pathStr[0].cElems; elemIndex++) { String path = files[elemIndex]; sccFiles.Add(path); // See if there are special files if (flags.Length > 0 && flags[0].cElems > 0) { int flag = Marshal.ReadInt32(flags[0].pElems, elemIndex); if (flag != 0) { // We have special files CALPOLESTR[] specialFiles = new CALPOLESTR[1]; CADWORD[] specialFlags = new CADWORD[1]; pscp2.GetSccSpecialFiles(itemid, path, specialFiles, specialFlags); string[] specialFileNames = GetFileNamesFromOleBuffer(specialFiles, true); foreach (var f in specialFileNames) { sccFiles.Add(f); } } } } } } return(sccFiles); }
public static string[] GetItemFiles(IVsSccProject2 project, uint itemId) { var itemFiles = new List <string>(); var files = new CALPOLESTR[1]; var flags = new CADWORD[1]; if (ErrorHandler.Succeeded(project.GetSccFiles(itemId, files, flags))) { var fileNames = GetFileNames(files[0]); for (int i = 0; i < files[0].cElems; i++) { itemFiles.Add(fileNames[i]); if (HasSpecialFiles(flags, i)) { itemFiles.AddRange(GetSpecialFiles(project, itemId, fileNames[i])); } } } return(itemFiles.ToArray()); }
/// <summary> /// Returns a list of source controllable files associated with the specified node /// </summary> private IList <string> GetNodeFiles(IVsSccProject2 pscp2, uint itemid) { // NOTE: the function returns only a list of files, containing both regular files and special files // If you want to hide the special files (similar with solution explorer), you may need to return // the special files in a hastable (key=master_file, values=special_file_list) // Initialize output parameters IList <string> sccFiles = new List <string>(); if (pscp2 != null) { CALPOLESTR[] pathStr = new CALPOLESTR[1]; CADWORD[] flags = new CADWORD[1]; if (pscp2.GetSccFiles(itemid, pathStr, flags) == 0) { for (int elemIndex = 0; elemIndex < pathStr[0].cElems; elemIndex++) { IntPtr pathIntPtr = Marshal.ReadIntPtr(pathStr[0].pElems, elemIndex); String path = Marshal.PtrToStringAuto(pathIntPtr); sccFiles.Add(path); // See if there are special files if (flags.Length > 0 && flags[0].cElems > 0) { int flag = Marshal.ReadInt32(flags[0].pElems, elemIndex); if (flag != 0) { // We have special files CALPOLESTR[] specialFiles = new CALPOLESTR[1]; CADWORD[] specialFlags = new CADWORD[1]; pscp2.GetSccSpecialFiles(itemid, path, specialFiles, specialFlags); for (int i = 0; i < specialFiles[0].cElems; i++) { IntPtr specialPathIntPtr = Marshal.ReadIntPtr(specialFiles[0].pElems, i * IntPtr.Size); String specialPath = Marshal.PtrToStringAuto(specialPathIntPtr); sccFiles.Add(specialPath); Marshal.FreeCoTaskMem(specialPathIntPtr); } if (specialFiles[0].cElems > 0) { Marshal.FreeCoTaskMem(specialFiles[0].pElems); } } } Marshal.FreeCoTaskMem(pathIntPtr); } if (pathStr[0].cElems > 0) { Marshal.FreeCoTaskMem(pathStr[0].pElems); } } } else if (itemid == VSConstants.VSITEMID_ROOT) { sccFiles.Add(GetSolutionFileName()); } return(sccFiles); }
/// <summary> /// Returns a list of source controllable files associated with the specified node /// </summary> private static async Task<IList<string>> GetNodeFiles(IVsSccProject2 pscp2, uint itemid) { // NOTE: the function returns only a list of files, containing both regular files and special files // If you want to hide the special files (similar with solution explorer), you may need to return // the special files in a hastable (key=master_file, values=special_file_list) // Initialize output parameters IList<string> sccFiles = new List<string>(); if (pscp2 != null) { CALPOLESTR[] pathStr = new CALPOLESTR[1]; CADWORD[] flags = new CADWORD[1]; await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); if (pscp2.GetSccFiles(itemid, pathStr, flags) == 0) { for (int elemIndex = 0; elemIndex < pathStr[0].cElems; elemIndex++) { IntPtr pathIntPtr = Marshal.ReadIntPtr(pathStr[0].pElems, elemIndex); String path = Marshal.PtrToStringAuto(pathIntPtr); sccFiles.Add(path); // See if there are special files if (flags.Length > 0 && flags[0].cElems > 0) { int flag = Marshal.ReadInt32(flags[0].pElems, elemIndex); if (flag != 0) { // We have special files CALPOLESTR[] specialFiles = new CALPOLESTR[1]; CADWORD[] specialFlags = new CADWORD[1]; pscp2.GetSccSpecialFiles(itemid, path, specialFiles, specialFlags); for (int i = 0; i < specialFiles[0].cElems; i++) { IntPtr specialPathIntPtr = Marshal.ReadIntPtr(specialFiles[0].pElems, i * IntPtr.Size); String specialPath = Marshal.PtrToStringAuto(specialPathIntPtr); sccFiles.Add(specialPath); Marshal.FreeCoTaskMem(specialPathIntPtr); } if (specialFiles[0].cElems > 0) { Marshal.FreeCoTaskMem(specialFiles[0].pElems); } } } Marshal.FreeCoTaskMem(pathIntPtr); } if (pathStr[0].cElems > 0) { Marshal.FreeCoTaskMem(pathStr[0].pElems); } } } else if (itemid == VSConstants.VSITEMID_ROOT) { sccFiles.Add(await GetSolutionFileName()); } return sccFiles; }
/// <summary> /// Returns a list of source controllable files associated with the specified node /// </summary> private IList<string> GetNodeFiles(IVsSccProject2 pscp2, uint itemid) { // NOTE: the function returns only a list of files, containing both regular files and special files // If you want to hide the special files (similar with solution explorer), you may need to return // the special files in a hastable (key=master_file, values=special_file_list) // Initialize output parameters IList<string> sccFiles = new List<string>(); if (pscp2 != null) { var pathStr = new CALPOLESTR[1]; var flags = new CADWORD[1]; if (pscp2.GetSccFiles(itemid, pathStr, flags) == 0) { for (int elemIndex = 0; elemIndex < pathStr[0].cElems; elemIndex++) { var pathIntPtr = Marshal.ReadIntPtr(pathStr[0].pElems, elemIndex); var path = Marshal.PtrToStringAuto(pathIntPtr); sccFiles.Add(path); // See if there are special files if (flags.Length > 0 && flags[0].cElems > 0) { int flag = Marshal.ReadInt32(flags[0].pElems, elemIndex); if (flag != 0) { // We have special files var specialFiles = new CALPOLESTR[1]; var specialFlags = new CADWORD[1]; pscp2.GetSccSpecialFiles(itemid, path, specialFiles, specialFlags); for (int i = 0; i < specialFiles[0].cElems; i++) { IntPtr specialPathIntPtr = Marshal.ReadIntPtr(specialFiles[0].pElems, i * IntPtr.Size); String specialPath = Marshal.PtrToStringAuto(specialPathIntPtr); sccFiles.Add(specialPath); Marshal.FreeCoTaskMem(specialPathIntPtr); } if (specialFiles[0].cElems > 0) { Marshal.FreeCoTaskMem(specialFiles[0].pElems); } } } Marshal.FreeCoTaskMem(pathIntPtr); } if (pathStr[0].cElems > 0) { Marshal.FreeCoTaskMem(pathStr[0].pElems); } } } return sccFiles; }
public int RegisterSccProject(IVsSccProject2 pscp2Project, string pszSccProjectName, string pszSccAuxPath, string pszSccLocalPath, string pszProvider) { if (ExpectedProjectName != null) { AreEqual(ExpectedProjectName, pszSccProjectName); } if (ExpectedAuxPath != null) { AreEqual(ExpectedAuxPath, pszSccAuxPath); } if (ExpectedLocalPath != null) { AreEqual(ExpectedLocalPath, pszSccLocalPath); } if (ExpectedProvider != null) { AreEqual(ExpectedProvider, pszProvider); } var project = _loadedProjects[pscp2Project] = new ProjectInfo(pscp2Project, pszSccProjectName); CALPOLESTR[] str = new CALPOLESTR[1]; CADWORD[] cadword = new CADWORD[1]; // try it once w/ VSITEMID_ROOT, make sure we get back just the project. if (ErrorHandler.Failed(pscp2Project.GetSccFiles(VSConstants.VSITEMID_ROOT, str, cadword))) { Fail("Failed to get SccFiles"); } AreEqual(UnpackCALPOLESTR(str[0]).Length, 1); object propRes; if (ErrorHandler.Failed(((IVsHierarchy)pscp2Project).GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_FirstChild, out propRes))) { Fail("Failed to get first child of root node"); } int curSibling = (int)propRes; while (ErrorHandler.Succeeded(((IVsHierarchy)pscp2Project).GetProperty((uint)curSibling, (int)__VSHPROPID.VSHPROPID_NextSibling, out propRes))) { curSibling = (int)propRes; if (curSibling == unchecked ((int)VSConstants.VSITEMID_NIL)) { break; } if (ErrorHandler.Failed(pscp2Project.GetSccFiles((uint)curSibling, str, cadword))) { Fail("Failed to get SccFiles"); } string[] files = UnpackCALPOLESTR(str[0]); foreach (var file in files) { uint pItemId; if (ErrorHandler.Succeeded(((IVsHierarchy)pscp2Project).ParseCanonicalName(file, out pItemId))) { project.Files.Add(file, new FileInfo(project, file, pItemId)); } } } // couple extra test cases to make sure we handle weird inputs... pscp2Project.GetSccFiles(VSConstants.VSITEMID_ROOT, null, null); pscp2Project.GetSccFiles(VSConstants.VSITEMID_ROOT, new CALPOLESTR[0], new CADWORD[0]); AreEqual(VSConstants.E_INVALIDARG, pscp2Project.GetSccFiles(VSConstants.VSITEMID_SELECTION, null, null)); AreEqual(VSConstants.E_INVALIDARG, pscp2Project.GetSccFiles(0xffffffff, null, null)); pscp2Project.GetSccSpecialFiles(VSConstants.VSITEMID_ROOT, "", str, cadword); pscp2Project.GetSccSpecialFiles(VSConstants.VSITEMID_ROOT, "", null, null); AreEqual(VSConstants.E_INVALIDARG, pscp2Project.GetSccSpecialFiles(VSConstants.VSITEMID_SELECTION, "", null, null)); AreEqual(VSConstants.E_INVALIDARG, pscp2Project.GetSccSpecialFiles(0xffffffff, "", null, null)); return(VSConstants.S_OK); }
//[CLSCompliant(false)] public static bool GetSccFiles(IVsHierarchy hierarchy, IVsSccProject2 sccProject, uint id, out string[] files, out int[] flags, bool includeNoScc, IDictionary<string, uint> map) { if (hierarchy == null) throw new ArgumentNullException("hierarchy"); int hr; bool ok = false; files = null; flags = null; try { if (sccProject != null) { CALPOLESTR[] str = new CALPOLESTR[1]; CADWORD[] dw = new CADWORD[1]; if (ErrorHandler.Succeeded(hr = sccProject.GetSccFiles(id, str, dw))) { files = GetFileNamesFromOleBuffer(str, true); flags = GetFlagsFromOleBuffer(dw, true); if (!includeNoScc || files.Length > 0) return ok = true; // We have a result else ok = true; // Try the GetMkDocument route to find an alternative } else if (hr != VSConstants.E_NOTIMPL) return false; // } // If sccProject2.GetSccFiles() returns E_NOTIMPL we must try GetMkDocument // We also try this if the item does not implement IVsSccProject2 IVsProject project = hierarchy as IVsProject; if (project != null) { string mkDocument; if (ErrorHandler.Succeeded(project.GetMkDocument(id, out mkDocument))) { if (!IsValidPath(mkDocument)) files = new string[0]; else files = new string[] { mkDocument }; return true; } return ok; // No need to check our interface for projects } if (hierarchy is IVsSolution) { return ok; // Will fail in GetCanonicalName in VS2008 SP1 Beta 1 } string name; try { if (ErrorHandler.Succeeded(hierarchy.GetCanonicalName(id, out name))) { if (IsValidPath(name, true)) { files = new string[] { name }; return true; } } } catch { } // Ok, this seems to error in some managed tree implementations like TFS :( return ok; } finally { if (ok && map != null && files != null) { foreach (string file in files) map[file] = id; } } }
/// <summary> /// Returns a list of source controllable files associated with the specified node /// </summary> private static IList <string> GetNodeFiles(IVsSccProject2 pscp2, uint itemid) { // NOTE: the function returns only a list of files, containing both regular files and special files // If you want to hide the special files (similar with solution explorer), you may need to return // the special files in a hashtable (key=master_file, values=special_file_list) // Initialize output parameters IList <string> sccFiles = new List <string>(); if (pscp2 != null) { var pathStr = new CALPOLESTR[1]; var flags = new CADWORD[1]; if (pscp2.GetSccFiles(itemid, pathStr, flags) == 0) { uint arraySize = pathStr[0].cElems; IntPtr arrayPtr = pathStr[0].pElems; for (int elemIndex = 0; elemIndex < arraySize; elemIndex++) { IntPtr pathIntPtr = Marshal.ReadIntPtr(arrayPtr, elemIndex * IntPtr.Size); String path; try { path = Marshal.PtrToStringAuto(pathIntPtr); } catch (Exception ex) { Log.Error("In GetNodeFiles: " + ex.Message); continue; } //Log.Debug(string.Format("Regular file: {0}", path)); does this continually for selected file sccFiles.Add(path); // See if there are special files uint flagsArraySize = flags[0].cElems; IntPtr flagsPtr = flags[0].pElems; if (flags.Length > 0 && flagsArraySize > 0) { int flag = Marshal.ReadInt32(flagsPtr, elemIndex); if (flag != 0) { // We have special files var specialFiles = new CALPOLESTR[1]; var specialFlags = new CADWORD[1]; pscp2.GetSccSpecialFiles(itemid, path, specialFiles, specialFlags); for (int i = 0; i < specialFiles[0].cElems; i++) { IntPtr specialPathIntPtr = Marshal.ReadIntPtr(specialFiles[0].pElems, i * IntPtr.Size); String specialPath = Marshal.PtrToStringAuto(specialPathIntPtr); //Log.Debug(string.Format("Special file: {0}", path)); sccFiles.Add(specialPath); Marshal.FreeCoTaskMem(specialPathIntPtr); } if (specialFiles[0].cElems > 0) { Marshal.FreeCoTaskMem(specialFiles[0].pElems); } } } Marshal.FreeCoTaskMem(pathIntPtr); } if (arraySize > 0) { Marshal.FreeCoTaskMem(arrayPtr); } } } return(sccFiles); }
public int RegisterSccProject(IVsSccProject2 pscp2Project, string pszSccProjectName, string pszSccAuxPath, string pszSccLocalPath, string pszProvider) { if (ExpectedProjectName != null) { AreEqual(ExpectedProjectName, pszSccProjectName); } if (ExpectedAuxPath != null) { AreEqual(ExpectedAuxPath, pszSccAuxPath); } if (ExpectedLocalPath != null) { AreEqual(ExpectedLocalPath, pszSccLocalPath); } if (ExpectedProvider != null) { AreEqual(ExpectedProvider, pszProvider); } var project = _loadedProjects[pscp2Project] = new ProjectInfo(pscp2Project, pszSccProjectName); CALPOLESTR[] str = new CALPOLESTR[1]; CADWORD[] cadword = new CADWORD[1]; // try it once w/ the correct item ID var projectId = GetItemId((IVsHierarchy)pscp2Project); if (ErrorHandler.Failed(pscp2Project.GetSccFiles(projectId, str, cadword))) { Fail("Failed to get SccFiles"); } string[] files = UnpackCALPOLESTR(str[0]); foreach (var file in files) { uint pItemId; if (ErrorHandler.Succeeded(((IVsHierarchy)pscp2Project).ParseCanonicalName(file, out pItemId))) { project.Files.Add(file, new FileInfo(project, file, pItemId)); } } // try it once w/ VSITEMID_ROOT, make sure we get the same count back... if (ErrorHandler.Failed(pscp2Project.GetSccFiles(VSConstants.VSITEMID_ROOT, str, cadword))) { Fail("Failed to get SccFiles"); } AreEqual(UnpackCALPOLESTR(str[0]).Length, files.Length); // couple extra test cases to make sure we handle weird inputs... pscp2Project.GetSccFiles(projectId, null, null); pscp2Project.GetSccFiles(projectId, new CALPOLESTR[0], new CADWORD[0]); AreEqual(VSConstants.E_INVALIDARG, pscp2Project.GetSccFiles(VSConstants.VSITEMID_SELECTION, null, null)); AreEqual(VSConstants.E_INVALIDARG, pscp2Project.GetSccFiles(0xffffffff, null, null)); pscp2Project.GetSccSpecialFiles(projectId, "", str, cadword); pscp2Project.GetSccSpecialFiles(projectId, "", null, null); AreEqual(VSConstants.E_INVALIDARG, pscp2Project.GetSccSpecialFiles(VSConstants.VSITEMID_SELECTION, "", null, null)); AreEqual(VSConstants.E_INVALIDARG, pscp2Project.GetSccSpecialFiles(0xffffffff, "", null, null)); return(VSConstants.S_OK); }
//[CLSCompliant(false)] public static bool GetSccFiles(IVsHierarchy hierarchy, IVsSccProject2 sccProject, uint id, out string[] files, out int[] flags, bool includeNoScc, IDictionary <string, uint> map) { ThreadHelper.ThrowIfNotOnUIThread(); if (hierarchy == null) { throw new ArgumentNullException("hierarchy"); } int hr; bool ok = false; files = null; flags = null; try { if (sccProject != null) { CALPOLESTR[] str = new CALPOLESTR[1]; CADWORD[] dw = new CADWORD[1]; if (VSErr.Succeeded(hr = sccProject.GetSccFiles(id, str, dw))) { files = GetFileNamesFromOleBuffer(str, true); flags = GetFlagsFromOleBuffer(dw, true); if (!includeNoScc || files.Length > 0) { return(ok = true); // We have a result } else { ok = true; // Try the GetMkDocument route to find an alternative } } else if (hr != VSErr.E_NOTIMPL) { return(false); // } } // If sccProject2.GetSccFiles() returns E_NOTIMPL we must try GetMkDocument // We also try this if the item does not implement IVsSccProject2 IVsProject project = hierarchy as IVsProject; if (project != null) { string mkDocument; try { if (VSErr.Succeeded(project.GetMkDocument(id, out mkDocument))) { if (!IsValidPath(mkDocument, true)) { files = new string[0]; } else { files = new string[] { mkDocument } }; return(true); } } catch { } return(ok); // No need to check our interface for projects } if (hierarchy is IVsSolution) { return(ok); // Will fail in GetCanonicalName in VS2008 SP1 Beta 1 } string name; try { if (VSErr.Succeeded(hierarchy.GetCanonicalName(id, out name))) { if (IsValidPath(name, true)) { files = new string[] { name }; return(true); } } } catch { } // Ok, this seems to error in some managed tree implementations like TFS :( return(ok); } finally { if (ok && map != null && files != null) { foreach (string file in files) { map[file] = id; } } } }
public int RegisterSccProject(IVsSccProject2 pscp2Project, string pszSccProjectName, string pszSccAuxPath, string pszSccLocalPath, string pszProvider) { if (ExpectedProjectName != null) { AreEqual(ExpectedProjectName, pszSccProjectName); } if (ExpectedAuxPath != null) { AreEqual(ExpectedAuxPath, pszSccAuxPath); } if (ExpectedLocalPath != null) { AreEqual(ExpectedLocalPath, pszSccLocalPath); } if (ExpectedProvider != null) { AreEqual(ExpectedProvider, pszProvider); } var project = _loadedProjects[pscp2Project] = new ProjectInfo(pscp2Project, pszSccProjectName); CALPOLESTR[] str = new CALPOLESTR[1]; CADWORD[] cadword = new CADWORD[1]; // try it once w/ VSITEMID_ROOT, make sure we get back just the project. if (ErrorHandler.Failed(pscp2Project.GetSccFiles(VSConstants.VSITEMID_ROOT, str, cadword))) { Fail("Failed to get SccFiles"); } AreEqual(UnpackCALPOLESTR(str[0]).Length, 1); object propRes; if(ErrorHandler.Failed(((IVsHierarchy)pscp2Project).GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_FirstChild, out propRes))) { Fail("Failed to get first child of root node"); } int curSibling = (int)propRes; while(ErrorHandler.Succeeded(((IVsHierarchy)pscp2Project).GetProperty((uint)curSibling, (int)__VSHPROPID.VSHPROPID_NextSibling, out propRes))) { curSibling = (int)propRes; if(curSibling == unchecked((int)VSConstants.VSITEMID_NIL)) { break; } if (ErrorHandler.Failed(pscp2Project.GetSccFiles((uint)curSibling, str, cadword))) { Fail("Failed to get SccFiles"); } string[] files = UnpackCALPOLESTR(str[0]); foreach (var file in files) { uint pItemId; if (ErrorHandler.Succeeded(((IVsHierarchy)pscp2Project).ParseCanonicalName(file, out pItemId))) { project.Files.Add(file, new FileInfo(project, file, pItemId)); } } } // couple extra test cases to make sure we handle weird inputs... pscp2Project.GetSccFiles(VSConstants.VSITEMID_ROOT, null, null); pscp2Project.GetSccFiles(VSConstants.VSITEMID_ROOT, new CALPOLESTR[0], new CADWORD[0]); AreEqual(VSConstants.E_INVALIDARG, pscp2Project.GetSccFiles(VSConstants.VSITEMID_SELECTION, null, null)); AreEqual(VSConstants.E_INVALIDARG, pscp2Project.GetSccFiles(0xffffffff, null, null)); pscp2Project.GetSccSpecialFiles(VSConstants.VSITEMID_ROOT, "", str, cadword); pscp2Project.GetSccSpecialFiles(VSConstants.VSITEMID_ROOT, "", null, null); AreEqual(VSConstants.E_INVALIDARG, pscp2Project.GetSccSpecialFiles(VSConstants.VSITEMID_SELECTION, "", null, null)); AreEqual(VSConstants.E_INVALIDARG, pscp2Project.GetSccSpecialFiles(0xffffffff, "", null, null)); return VSConstants.S_OK; }
/// <summary> /// Returns a list of source controllable files associated with the specified node /// </summary> public IList <string> GetNodeFiles(IVsSccProject2 pscp2, uint itemid) { // NOTE: the function returns only a list of files, containing both regular files and special files // If you want to hide the special files (similar with solution explorer), you may need to return // the special files in a hashtable (key=master_file, values=special_file_list) // Initialize output parameters IList <string> sccFiles = new List <string>(); if (pscp2 != null) { CALPOLESTR[] pathStr = new CALPOLESTR[1]; CADWORD[] flags = new CADWORD[1]; if (pscp2.GetSccFiles(itemid, pathStr, flags) == VSConstants.S_OK) { if (pathStr[0].cElems > 0) { for (int elemIndex = 0; elemIndex < pathStr[0].cElems; elemIndex++) { IntPtr pathIntPtr = Marshal.ReadIntPtr(pathStr[0].pElems, elemIndex * IntPtr.Size); String path = Marshal.PtrToStringAuto(pathIntPtr); sccFiles.Add(path); // See if there are special files if (flags.Length > 0 && flags[0].cElems > 0) { int flag = Marshal.ReadInt32(flags[0].pElems, elemIndex * IntPtr.Size); if (flag != 0) { // We have special files CALPOLESTR[] specialFiles = new CALPOLESTR[1]; CADWORD[] specialFlags = new CADWORD[1]; if (pscp2.GetSccSpecialFiles(itemid, path, specialFiles, specialFlags) == VSConstants.S_OK) { for (int i = 0; i < specialFiles[0].cElems; i++) { IntPtr specialPathIntPtr = Marshal.ReadIntPtr(specialFiles[0].pElems, i * IntPtr.Size); String specialPath = Marshal.PtrToStringAuto(specialPathIntPtr); sccFiles.Add(specialPath); Marshal.FreeCoTaskMem(specialPathIntPtr); } if (specialFiles[0].cElems > 0) { Marshal.FreeCoTaskMem(specialFiles[0].pElems); } } } } Marshal.FreeCoTaskMem(pathIntPtr); } } else { // This is a special file, so the GetSccFiles will not return it's path, // so get it directly from the project string path = string.Empty; IVsProject pscp = pscp2 as IVsProject; if (pscp != null) { pscp.GetMkDocument(itemid, out path); } // can't be null, blank or end with back slash (that's a directory) if ((string.IsNullOrEmpty(path) == false) && (path.EndsWith("\\") == false) && (SccService.ScmProvider.IsFileCached(path))) { //got a valid path sccFiles.Add(path); } } } } return(sccFiles); }
public static string[] GetItemFiles(IVsSccProject2 project, uint itemId) { var itemFiles = new List<string>(); var files = new CALPOLESTR[1]; var flags = new CADWORD[1]; if (ErrorHandler.Succeeded(project.GetSccFiles(itemId, files, flags))) { var fileNames = GetFileNames(files[0]); for (int i = 0; i < files[0].cElems; i++) { itemFiles.Add(fileNames[i]); if (HasSpecialFiles(flags, i)) { itemFiles.AddRange(GetSpecialFiles(project, itemId, fileNames[i])); } } } return itemFiles.ToArray(); }