/// <summary>Load the file in the VE (with plugin autodetection)</summary> /// <param name="URL">The file's URL</param> /// <param name="FS">The file's filesystem</param> /// <param name="AllowEdit">Mode of VE: true=editor, false=viewer</param> public void LoadFile(string URL, pluginner.IFSPlugin FS, bool AllowEdit) { byte[] ContentBytes = FS.GetFileContent(URL); string content = (ContentBytes != null && ContentBytes.Length > 0) ? Encoding.UTF8.GetString(ContentBytes) : ""; pluginfinder pf = new pluginfinder(); try { string GottenHeaders; if (content.Length >= 20) { GottenHeaders = content.Substring(0, 20); } else { GottenHeaders = content; } LoadFile(URL, FS, pf.GetFCVEplugin("NAME=" + URL + "HEADERS=" + GottenHeaders), AllowEdit); } catch (pluginfinder.PluginNotFoundException ex) { Console.WriteLine("ERROR: VE plugin is not loaded: " + ex.Message + "\n" + ex.StackTrace); Xwt.MessageDialog.ShowError(Locale.GetString("FCVE_PluginNotFound")); LoadFile(URL, FS, new base_plugins.ve.PlainText(), AllowEdit); } catch (Exception ex) { Xwt.MessageDialog.ShowError(string.Format(Locale.GetString("FCVE_LoadError"), ex.Message)); Console.WriteLine("ERROR: VE can't load file: " + ex.Message + "\n" + ex.StackTrace); return; } }
/// <summary> /// Reads the file <paramref name="url"/> and returns it as string /// (for File Commander's CLI panel) /// </summary> /// <param name="url"></param> /// <returns></returns> public string Cat(string url) { pluginner.IFSPlugin fs = ActivePanel.FS; if (!fs.FileExists(url)) { return("Файл не найден\n"); } return(Encoding.ASCII.GetString(fs.GetFileContent(url))); }
/* ЗАМЕТКА РАЗРАБОТЧИКУ * * В данном файле размещаются подпрограммы для управления файлами, которые * вызываются из MainWindow.cs. Также планируется использование этих подпрограмм * после реализации текстовой коммандной строки FC (которая внизу окна). * Все комманды работают с активной и пассивой панелью - Active/PassivePanel. * FC всегда их определяет сам. Пассивая панель - всегда получатель файлов. * Названия комманд - UNIX в верблюжьем регистре (Ls, Rm, MkDir, Touch и т.п.). * Всем коммандам параметры передаются строкой, но допускаются исключения, напр., * если базовая функция "перегружена" функцией для нужд графического интерфейса. * Sorry for my bad english. */ /// <summary> /// Reads the file <paramref name="url"/> and shows in FC Viewer /// </summary> /// <param name="url"></param> public void FCView(string url) { VEd fcv = new VEd(); pluginner.IFSPlugin fs = ActivePanel.FS; if (!fs.FileExists(url)) { //MessageBox.Show(string.Format(locale.GetString("FileNotFound"), ActivePanel.list.SelectedItems[0].Text), "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Xwt.MessageDialog.ShowError(string.Format(Locale.GetString("FileNotFound"), ActivePanel.GetValue(ActivePanel.dfDisplayName))); return; } pluginner.File SelectedFile = fs.GetFile(url, new int()); string FileContent = Encoding.ASCII.GetString(fs.GetFileContent(url)); fcv.LoadFile(url, ActivePanel.FS, false); fcv.Show(); }
public void OpenFile(string url, pluginner.IFSPlugin fsplugin) { lblFileName.Text = url; fileContent = fsplugin.GetFileContent(url); ChangeCodepage(Codepage); }