Esempio n. 1
0
        /// <summary>
        /// Checks if the file name is a settings file. If so, the contained logfile name
        /// is returned. If not, the given file name is returned unchanged.
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        private string FindFilenameForSettings(string fileName)
        {
            if (fileName.EndsWith(".lxp"))
            {
                PersistenceData persistenceData = Persister.LoadOptionsOnly(fileName);
                if (persistenceData == null)
                {
                    return(fileName);
                }

                if (persistenceData.fileName != null && persistenceData.fileName.Length > 0)
                {
                    IFileSystemPlugin fs = PluginRegistry.GetInstance().FindFileSystemForUri(persistenceData.fileName);
                    if (fs != null && !fs.GetType().Equals(typeof(LocalFileSystem)))
                    {
                        return(persistenceData.fileName);
                    }

                    // On relative paths the URI check (and therefore the file system plugin check) will fail.
                    // So fs == null and fs == LocalFileSystem are handled here like normal files.
                    if (Path.IsPathRooted(persistenceData.fileName))
                    {
                        return(persistenceData.fileName);
                    }
                    else
                    {
                        // handle relative paths in .lxp files
                        string dir = Path.GetDirectoryName(fileName);
                        return(Path.Combine(dir, persistenceData.fileName));
                    }
                }
            }

            return(fileName);
        }