private static Icon GetIcon(string path, FILE_ATTRIBUTE dwAttr, SHGFI dwFlag) { SHFILEINFO sfi = new SHFILEINFO(); int num = (int)SHGetFileInfo(path, dwAttr, ref sfi, 0, dwFlag); return(Icon.FromHandle(sfi.hIcon)); }
protected override bool CanShowOverlay(string path, FILE_ATTRIBUTE attributes) { _path = path; var client = ServiceClient.CreateServiceClient(this, 8743); try { var repos = JsonConvert.DeserializeObject <GinRepositoryData[]>(client.GetRepositoryList()); var directory = new DirectoryInfo(path); var result = false; GinRepositoryData data; foreach (var repo in repos) { if (!path.Contains(repo.Mountpoint.FullName)) { continue; } result = true; _fstatus = JsonConvert.DeserializeObject < Dictionary <string, GinRepository.FileStatus> >(client.GetRepositoryFileInfo(repo.Name)); break; } ((ICommunicationObject)client).Close(); return(result); } catch { ((ICommunicationObject)client).Abort(); return(false); } }
protected override bool CanShowOverlay(string path, FILE_ATTRIBUTE attributes) { return(false); //Disable this for now! //_path = path; //var client = ServiceClient.CreateServiceClient(this, 8743); //try //{ // var repos = JsonConvert.DeserializeObject<GinRepositoryData[]>(client.GetRepositoryList()); // var result = false; // foreach (var repo in repos) // { // if (!path.Contains(repo.Mountpoint.FullName)) continue; // result = true; // _fstatus = JsonConvert.DeserializeObject< // Dictionary<string, GinRepository.FileStatus>>(client.GetRepositoryFileInfo(repo.Name)); // break; // } // client.EndSession(); // ((ICommunicationObject) client).Close(); // return result; //} //catch //{ // ((ICommunicationObject) client).Abort(); // return false; //} }
public override SyncInformation BuildInformation(string path, FILE_ATTRIBUTE attributes) { return(new FolderSyncInformation { Name = Path.GetDirectoryName(path) }); }
public static extern IntPtr SHGetFileInfo( string pszPath, FILE_ATTRIBUTE dwFileAttributes, ref SHFILEINFO psfi, uint cbFileInfo, SHGetFileInfoConstants uFlags );
public static SyncInformationBuilder GetInformationBuilder(string path, FILE_ATTRIBUTE attributes) { switch (attributes) { case FILE_ATTRIBUTE.FILE_ATTRIBUTE_ARCHIVE: case FILE_ATTRIBUTE.FILE_ATTRIBUTE_COMPRESSED: case FILE_ATTRIBUTE.FILE_ATTRIBUTE_DEVICE: case FILE_ATTRIBUTE.FILE_ATTRIBUTE_ENCRYPTED: case FILE_ATTRIBUTE.FILE_ATTRIBUTE_HIDDEN: case FILE_ATTRIBUTE.FILE_ATTRIBUTE_INTEGRITY_STREAM: case FILE_ATTRIBUTE.FILE_ATTRIBUTE_NORMAL: case FILE_ATTRIBUTE.FILE_ATTRIBUTE_NOT_CONTENT_INDEXED: case FILE_ATTRIBUTE.FILE_ATTRIBUTE_NO_SCRUB_DATA: case FILE_ATTRIBUTE.FILE_ATTRIBUTE_OFFLINE: case FILE_ATTRIBUTE.FILE_ATTRIBUTE_READONLY: case FILE_ATTRIBUTE.FILE_ATTRIBUTE_REPARSE_POINT: case FILE_ATTRIBUTE.FILE_ATTRIBUTE_SPARSE_FILE: case FILE_ATTRIBUTE.FILE_ATTRIBUTE_SYSTEM: case FILE_ATTRIBUTE.FILE_ATTRIBUTE_TEMPORARY: case FILE_ATTRIBUTE.FILE_ATTRIBUTE_VIRTUAL: return(new FileSyncInformationBuilder(path, attributes)); case FILE_ATTRIBUTE.FILE_ATTRIBUTE_DIRECTORY: return(new FolderSyncInformationBuilder(path, attributes)); default: throw new ArgumentOutOfRangeException("attributes"); } }
protected override bool CanShowOverlay(string path, FILE_ATTRIBUTE attributes) { try { if (ApplicationUtil.ProcessName != "explorer") { return(false); } //把优先级最高的结果缓存 低优先级直接读缓存 //if (_notGitList.Contains(path)) // return false; //LogUtil.Log("{0}: Process is getting the show state of {1}", Status, path); if (Status == FirstAccessStatus) { _statusMap[path] = GitUtil.GetStatus(path); } //_notGitList.Add(path);空文件夹检出项目时会混乱 虽然降效率了 没有太好的办法 //LogUtil.Log("{0}: Process has got the show state of {1}", Status, path); return(Status == _statusMap[path]); } catch (Exception ex) { ex.HelpLink = Status + " " + path; LogUtil.Log(ex); return(false); } }
public virtual void PostNewItem ( TSF dwFlags, IShellItem psiDestinationFolder, string pszNewName, string pszTemplateName, FILE_ATTRIBUTE dwFileAttributes, int hrNew, IShellItem psiNewItem ) { this.fileOperation.OnPostNew?.Invoke ( this.fileOperation, new PostNewEventArgs ( (TransferSourceFlags)dwFlags, psiDestinationFolder.GetDisplayName(SIGDN.DESKTOPABSOLUTEPARSING), pszNewName, pszTemplateName, (FileAttributes)dwFileAttributes, psiNewItem.GetDisplayName(SIGDN.DESKTOPABSOLUTEPARSING), hrNew ) ); }
protected override bool CanShowOverlay(string path, FILE_ATTRIBUTE attributes) { try { AllocConsole(); Console.WriteLine("=37="); try { ShowMessageBox("Explorer Gocha!", "COM PoC"); } catch (Exception e) { Console.WriteLine(e.Message); Console.ReadLine(); } // Get the file attributes. var fileAttributes = new FileInfo(path); // Return true if the file is read only, meaning we'll show the overlay. return(fileAttributes.IsReadOnly); } catch (Exception) { return(false); } }
public override SyncInformation BuildInformation(string path, FILE_ATTRIBUTE attributes) { return(new FileSyncInformation { Name = path }); }
/// <summary> /// 获取系统图标 /// </summary> /// <param name="path">文件名</param> /// <param name="dwAttr">文件信息</param> /// <param name="dwFlag">获取信息控制字</param> /// <returns></returns> private Icon GetIcon( string path, FILE_ATTRIBUTE dwAttr, SHGFI dwFlag) { SHFILEINFO fi = new SHFILEINFO(); Icon ic = null; int iTotal = (int)SHGetFileInfo(path, dwAttr, ref fi, 0, dwFlag); ic = Icon.FromHandle(fi.hIcon); return ic; }
IntPtr CreateFile( string lpFileName, ACCESS dwDesiredAccess, FILE_SHARE dwShareMode, int Res, FILE_ACTION dwCreationDispostion, FILE_ATTRIBUTE dwFlagsAndAttributes, int Res2);
private static Icon GetIcon(string path, FILE_ATTRIBUTE dwAttr, SHGFI dwFlag) { SHFILEINFO fi = new SHFILEINFO(); Icon ic = null; int iTotal = (int)SHGetFileInfo(path, dwAttr, ref fi, 0, dwFlag); ic = Icon.FromHandle(fi.hIcon); return(ic); }
protected override bool CanShowOverlay(string path, FILE_ATTRIBUTE attributes) { // Return true if the file is read only, meaning we'll show the overlay. try { string app = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); string dbPath = Path.Combine(app, @"yliyun\db\file_status.db"); using (SqliteConnection conn = new SqliteConnection("Data Source =" + dbPath)) { string rootDir = @"D:\一粒云盘"; conn.Open(); SqliteCommand cmd1 = new SqliteCommand("SELECT syncRoot FROM yliyun_conf", conn); SqliteDataReader reader1 = cmd1.ExecuteReader(); if (reader1.Read()) { rootDir = reader1.GetString(0); } if (path.StartsWith(Path.Combine(rootDir, @"个人空间\")) || path.StartsWith(Path.Combine(rootDir, @"群组空间\")) || path.StartsWith(Path.Combine(rootDir, @"部门空间\")) || path.StartsWith(Path.Combine(rootDir, @"共享空间\"))) { string sql = "SELECT lastModified FROM file_status WHERE filePath = @fp"; SqliteCommand cmd = new SqliteCommand(sql, conn); cmd.Parameters.AddRange(new[] { new SqliteParameter("@fp", path) }); SqliteDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { return false; } else { return true; } } else { return false; } } } catch (Exception) { return false; } }
protected override bool CanShowOverlay(string path, FILE_ATTRIBUTE attributes) { #if DEBUG var result = TestIfFileIsLocked(path); var name = Path.GetFileName(path); Log(name + " is " + (result ? "locked" : "not locked")); return(result); #else return(TestIfFileIsLocked(path)); #endif }
/// <summary> /// Determines whether an overlay should be shown for the shell item with the path 'path' and /// the shell attributes 'attributes'. /// </summary> /// <param name="path">The path for the shell item. This is not necessarily the path /// to a physical file or folder.</param> /// <param name="attributes">The attributes of the shell item.</param> /// <returns> /// <c>true</c> if this an overlay should be shown for the specified item; otherwise, <c>false</c>. /// </returns> /// <exception cref="System.NotImplementedException"></exception> protected override bool CanShowOverlay(string path, FILE_ATTRIBUTE attributes) { #if DEBUG var result = TestIfFileIsLocked(path); var name = Path.GetFileName(path); Log(name + " is " + (result ? "locked" : "not locked")); return result; #else return TestIfFileIsLocked(path); #endif }
protected override bool CanShowOverlay(string path, FILE_ATTRIBUTE attributes) { try { // Get the file attributes. //var fileAttributes = new FileInfo(path); if (File.Exists(path + ".sha")) { FileInfo info = new FileInfo(path); long mb = (info.Length / 1024) / 1024; appLog.WriteEntry("File: " + path + " size: " + mb + " MB"); if (mb > 500 && System.Windows.Forms.MessageBox.Show(info.Name + " is over 500MB do you want to check file?", "FileHasher", System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No) { return(false); } string hash = readhashes(path + ".sha"); if (hashfile(path) == hash) { type = (int)icontype.hashok; appLog.WriteEntry("Hash OK: " + path, System.Diagnostics.EventLogEntryType.Information); //System.Windows.Forms.MessageBox.Show(type.ToString()); return(true); } else { appLog.WriteEntry("Hash Fail: " + path, System.Diagnostics.EventLogEntryType.Information); //type = (int)icontype.hashwrong; //System.Windows.Forms.MessageBox.Show(type.ToString()); //return true; return(false); } } else { //type = (int)icontype.nohash; //System.Windows.Forms.MessageBox.Show(type.ToString()); // return true; return(false); } return(false); } catch (Exception e) { //type = (int)icontype.nohash; //return true; appLog.WriteEntry(e.Message + e.StackTrace, System.Diagnostics.EventLogEntryType.Warning); return(false); } }
protected override bool CanShowOverlay(string path, FILE_ATTRIBUTE attributes) { try { var info = GetSyncInformation(path, attributes); return(CanShowOverlay(info)); } catch (Exception) { return(false); } }
protected override bool CanShowOverlay(string path, FILE_ATTRIBUTE attributes) { try { // Get the file attributes. var fileAttributes = new FileInfo(path); // Return true if the file is read only, meaning we'll show the overlay. return(fileAttributes.IsReadOnly); } catch (Exception) { return(false); } }
/// <summary> /// Determines whether an overlay should be shown for the shell item with the path 'path' and /// the shell attributes 'attributes'. /// </summary> /// <param name="path">The path for the shell item. This is not necessarily the path /// to a physical file or folder.</param> /// <param name="attributes">The attributes of the shell item.</param> /// <returns> /// <c>true</c> if this an overlay should be shown for the specified item; otherwise, <c>false</c>. /// </returns> protected override bool CanShowOverlay(string path, FILE_ATTRIBUTE attributes) { try { // Get the file attributes. var fileAttributes = new FileInfo(path); // Return true if the file is read only, meaning we'll show the overlay. return fileAttributes.IsReadOnly; } catch (Exception) { return false; } }
/// <summary> /// Specifies whether an icon overlay should be added to a Shell object's icon. /// </summary> /// <param name="pwszPath">A Unicode string that contains the fully qualified path of the Shell object.</param> /// <param name="dwAttrib">The object's attributes. For a complete list of file attributes and their associated flags, see IShellFolder::GetAttributesOf.</param> /// <returns> /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// </returns> int IShellIconOverlayIdentifier.IsMemberOf(string pwszPath, FILE_ATTRIBUTE dwAttrib) { // Always wrap calls to the abstract functions in exception handlers. try { // Can we show the overla? var canShowOverly = CanShowOverlay(pwszPath, dwAttrib); // DebugLog this key event. Log(string.Format("IsMemberOf for {0} - returning {1}", pwszPath, canShowOverly)); // Return OK if we should show the overlay, otherwise false. return canShowOverly ? WinError.S_OK : WinError.S_FALSE; } catch (Exception exception) { // DebugLog the exception. LogError("IsMemberOf: An exception occured when determining whether to show the overlay for '" + pwszPath + "'.", exception); // Return false so we don't try and get the icon for a server that is erroring. return WinError.S_FALSE; } }
/// <summary> /// Specifies whether an icon overlay should be added to a Shell object's icon. /// </summary> /// <param name="pwszPath">A Unicode string that contains the fully qualified path of the Shell object.</param> /// <param name="dwAttrib">The object's attributes. For a complete list of file attributes and their associated flags, see IShellFolder::GetAttributesOf.</param> /// <returns> /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// </returns> int IShellIconOverlayIdentifier.IsMemberOf(string pwszPath, FILE_ATTRIBUTE dwAttrib) { // Always wrap calls to the abstract functions in exception handlers. try { // Can we show the overla? var canShowOverly = CanShowOverlay(pwszPath, dwAttrib); // Log this key event. Log(string.Format("IsMemberOf for {0} - returning {1}", pwszPath, canShowOverly)); // Return OK if we should show the overlay, otherwise false. return(canShowOverly ? WinError.S_OK : WinError.S_FALSE); } catch (Exception exception) { // Log the exception. LogError("IsMemberOf: An exception occured when determining whether to show the overlay for '" + pwszPath + "'.", exception); // Return false so we don't try and get the icon for a server that is erroring. return(WinError.S_FALSE); } }
static extern bool PathRelativePathTo(StringBuilder lpszDst, string from, FILE_ATTRIBUTE attrFrom, string to, FILE_ATTRIBUTE attrTo);
private static bool IsFileImpl(FILE_ATTRIBUTE data) { return (data & FILE_ATTRIBUTE.FILE_ATTRIBUTE_DIRECTORY) == 0; }
/// <summary> /// Determines whether an overlay should be shown for the shell item with the path 'path' and /// the shell attributes 'attributes'. /// </summary> /// <param name="path">The path for the shell item. This is not necessarily the path /// to a physical file or folder.</param> /// <param name="attributes">The attributes of the shell item.</param> /// <returns> /// <c>true</c> if this an overlay should be shown for the specified item; otherwise, <c>false</c>. /// </returns> protected abstract bool CanShowOverlay(string path, FILE_ATTRIBUTE attributes);
public static extern IntPtr SHGetFileInfo( IntPtr ppidl, FILE_ATTRIBUTE dwFileAttributes, ref SHFILEINFO sfi, int cbFileInfo, SHGFI uFlags);
public static extern bool SetFileAttributes([In] [MarshalAs(UnmanagedType.LPTStr)] string lpFileName, FILE_ATTRIBUTE dwFileAttributes);
private static extern IntPtr SHGetFileInfo( string pszPath, //指定的文件名 FILE_ATTRIBUTE dwFileAttributes, //文件属性 ref SHFILEINFO sfi, //返回获得的文件信息,是一个记录类型 int cbFileInfo, //文件的类型名 SHGFI uFlags);
private static bool IsDirectoryImpl(FILE_ATTRIBUTE data) { return (data & FILE_ATTRIBUTE.FILE_ATTRIBUTE_DIRECTORY) != 0; }
private static extern IntPtr SHGetFileInfo(string pszPath, FILE_ATTRIBUTE dwFileAttributes, ref SHFILEINFO sfi, int cbFileInfo, SHGFI uFlags);
private static bool IsSymLinkImpl(FILE_ATTRIBUTE data) { return (data & FILE_ATTRIBUTE.FILE_ATTRIBUTE_REPARSE_POINT) != 0; }
public static extern IntPtr SHGetFileInfo(string Path, FILE_ATTRIBUTE fileAttributes, out SHFILEINFO sfi, int cbFileInfo, SHGFI flags);
private static Icon GetIcon(string path, FILE_ATTRIBUTE dwAttr, SHGFI dwFlag) { SHFILEINFO sfi = new SHFILEINFO(); int num1 = (int)SHGetFileInfo(path, dwAttr, ref sfi, 0, dwFlag); return Icon.FromHandle(sfi.hIcon); }
public static extern IntPtr CreateFile(string lpFileName, uint dwDesiredAccess, FILE_SHARE dwShareMode, [In] ref SECURITY_ATTRIBUTES lpSecurityAttributes, FileMode dwCreationDisposition, FILE_ATTRIBUTE dwFlagsAndAttributes, IntPtr hTemplateFile);
protected override bool CanShowOverlay(string targetFile, FILE_ATTRIBUTE attributes) { if (!showOverlay() || !P4EXPProgram.connectionSuccess) { return(false); } try { // TODO: need to check archive too? if (attributes.HasFlag(FILE_ATTRIBUTE.FILE_ATTRIBUTE_DIRECTORY)) { // ignoring directories for now (like current p4exp) return(false); } } catch (Exception) { // likely a dvd drive that causes the failure, so just return //FileLogger.LogException("Check for display of checked-out icon", ex); return(false); } FileMetaData fmd = null; try { P4EXPProgram.Connect(targetFile); fmd = P4EXPProgram.GetFileMetaData(targetFile); } catch (P4Exception ex) { if (P4EXPProgram.IsLoginException(ex.ErrorCode)) { // login and try again P4EXPProgram.Login(targetFile); fmd = P4EXPProgram.GetFileMetaData(targetFile); } else if (P4EXPProgram.showP4Exception()) { string message = ex.Message + "\n" + ex.StackTrace + "\n" + ex.TargetSite.Name; Message dlg = new Message(Properties.Resources.MessageDlg_P4Exception, message); dlg.ShowDialog(); } } catch (Exception ex) { if (P4EXPProgram.showException()) { string message = ex.Message + "\n" + ex.StackTrace + "\n" + ex.TargetSite.Name; Message dlg = new Message(Properties.Resources.MessageDlg_Exception, message); dlg.ShowDialog(); } //FileLogger.LogException("Check for display of checked-out icon", ex); } if (fmd != null) { return(CheckAction(fmd)); } return(false); }
protected override bool CanShowOverlay(string path, FILE_ATTRIBUTE attributes) => CanShowIconOverlay(path);
public DirectoryEntry(string name, FILE_ATTRIBUTE attributes) { _name = name; _attributes = attributes; }
private extern static IntPtr SHGetFileInfo ( string pszPath, //指定的文件名 FILE_ATTRIBUTE dwFileAttributes, //文件属性 ref SHFILEINFO sfi, //返回获得的文件信息,是一个记录类型 int cbFileInfo, //文件的类型名 SHGFI uFlags );
public static extern IntPtr CreateFile(string lpFileName, STANDARD_RIGHTS dwDesiredAccess, FILE_SHARE dwShareMode, IntPtr lpSecurityAttributes, FileMode dwCreationDisposition, FILE_ATTRIBUTE dwFlagsAndAttributes, IntPtr hTemplateFile);
protected override bool CanShowOverlay(string path, FILE_ATTRIBUTE attributes) { return(Database.GetTag(path) == "Green"); }
private static SyncInformation GetSyncInformation(string path, FILE_ATTRIBUTE attributes) { var builder = InformationBuilderFactory.GetInformationBuilder(path, attributes); return(builder.BuildInformation(path, attributes)); }