/// <summary> /// Load a KDBX file. /// </summary> /// <param name="strFilePath">File to load.</param> /// <param name="fmt">Format.</param> /// <param name="slLogger">Status logger (optional).</param> public void Load(string strFilePath, KdbxFormat fmt, IStatusLogger slLogger) { IOConnectionInfo ioc = IOConnectionInfo.FromPath(strFilePath); Load(IOConnection.OpenRead(ioc), fmt, slLogger); }
public FileTransactionEx(IOConnectionInfo iocBaseFile, bool bTransacted) { if (iocBaseFile == null) { throw new ArgumentNullException("iocBaseFile"); } m_bTransacted = bTransacted; m_iocBase = iocBaseFile.CloneDeep(); if (m_iocBase.IsLocalFile()) { m_iocBase.Path = UrlUtil.GetShortestAbsolutePath(m_iocBase.Path); } string strPath = m_iocBase.Path; #if !ModernKeePassLib if (m_iocBase.IsLocalFile()) { try { if (File.Exists(strPath)) { // Symbolic links are realized via reparse points; // https://msdn.microsoft.com/en-us/library/windows/desktop/aa365503.aspx // https://msdn.microsoft.com/en-us/library/windows/desktop/aa365680.aspx // https://msdn.microsoft.com/en-us/library/windows/desktop/aa365006.aspx // Performing a file transaction on a symbolic link // would delete/replace the symbolic link instead of // writing to its target FileAttributes fa = File.GetAttributes(strPath); if ((long)(fa & FileAttributes.ReparsePoint) != 0) { m_bTransacted = false; } } else { // If the base and the temporary file are in different // folders and the base file doesn't exist (i.e. we can't // backup the ACL), a transaction would cause the new file // to have the default ACL of the temporary folder instead // of the one of the base folder; therefore, we don't use // a transaction when the base file doesn't exist (this // also results in other applications monitoring the folder // to see one file creation only) m_bTransacted = false; } } catch (Exception) { Debug.Assert(false); } } #endif #if !ModernKeePassLib // Prevent transactions for FTP URLs under .NET 4.0 in order to // avoid/workaround .NET bug 621450: // https://connect.microsoft.com/VisualStudio/feedback/details/621450/problem-renaming-file-on-ftp-server-using-ftpwebrequest-in-net-framework-4-0-vs2010-only if (strPath.StartsWith("ftp:", StrUtil.CaseIgnoreCmp) && (Environment.Version.Major >= 4) && !NativeLib.IsUnix()) { m_bTransacted = false; } #endif foreach (KeyValuePair <string, bool> kvp in g_dEnabled) { if (strPath.StartsWith(kvp.Key, StrUtil.CaseIgnoreCmp)) { m_bTransacted = kvp.Value; break; } } if (m_bTransacted) { m_iocTemp = m_iocBase.CloneDeep(); m_iocTemp.Path += StrTempSuffix; TxfPrepare(); // Adjusts m_iocTemp } else { m_iocTemp = m_iocBase; } }
public void Load(StorageFile file, KdbxFormat fmt, IStatusLogger slLogger) { IOConnectionInfo ioc = IOConnectionInfo.FromFile(file); Load(IOConnection.OpenRead(ioc), fmt, slLogger); }
public FileTransactionEx(IOConnectionInfo iocBaseFile) : this(iocBaseFile, true) { }