Skip to content

Commit

Permalink
Add symlink support.
Browse files Browse the repository at this point in the history
Former-commit-id: 713323240cc14a8d6445badcf6f2046ab874d2e0
  • Loading branch information
ylangisc committed Oct 18, 2012
1 parent 74b5f5e commit beff3a4
Show file tree
Hide file tree
Showing 6 changed files with 328 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitattributes
Expand Up @@ -2625,6 +2625,7 @@ source/ch/cyberduck/ui/controller/BrowserController.cs -text
source/ch/cyberduck/ui/controller/ConnectionController.cs -text
source/ch/cyberduck/ui/controller/Controller.cs -text
source/ch/cyberduck/ui/controller/CreateFileController.cs -text
source/ch/cyberduck/ui/controller/CreateSymlinkController.cs -text
source/ch/cyberduck/ui/controller/DataProtector.cs -text
source/ch/cyberduck/ui/controller/DonationController.cs -text
source/ch/cyberduck/ui/controller/DownloadPromptController.cs -text
Expand All @@ -2644,6 +2645,7 @@ source/ch/cyberduck/ui/controller/IBookmarkView.cs -text
source/ch/cyberduck/ui/controller/IBrowserView.cs -text
source/ch/cyberduck/ui/controller/IConnectionView.cs -text
source/ch/cyberduck/ui/controller/ICreateFilePromptView.cs -text
source/ch/cyberduck/ui/controller/ICreateSymlinkPromptView.cs -text
source/ch/cyberduck/ui/controller/IDonationView.cs -text
source/ch/cyberduck/ui/controller/IDuplicateFilePromptView.cs -text
source/ch/cyberduck/ui/controller/IErrorView.cs -text
Expand Down Expand Up @@ -2712,6 +2714,9 @@ source/ch/cyberduck/ui/winforms/ConnectionForm.resx -text
source/ch/cyberduck/ui/winforms/CreateFilePromptForm.Designer.cs -text
source/ch/cyberduck/ui/winforms/CreateFilePromptForm.cs -text
source/ch/cyberduck/ui/winforms/CreateFilePromptForm.resx -text
source/ch/cyberduck/ui/winforms/CreateSymlinkPromptForm.Designer.cs -text
source/ch/cyberduck/ui/winforms/CreateSymlinkPromptForm.cs -text
source/ch/cyberduck/ui/winforms/CreateSymlinkPromptForm.resx -text
source/ch/cyberduck/ui/winforms/DonationForm.Designer.cs -text
source/ch/cyberduck/ui/winforms/DonationForm.cs -text
source/ch/cyberduck/ui/winforms/DonationForm.resx -text
Expand Down
89 changes: 89 additions & 0 deletions source/ch/cyberduck/ui/controller/CreateSymlinkController.cs
@@ -0,0 +1,89 @@
//
// Copyright (c) 2010-2012 Yves Langisch. All rights reserved.
// http://cyberduck.ch/
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// Bug fixes, suggestions and comments should be sent to:
// yves@cyberduck.ch
//

using System;
using System.Drawing;
using System.Windows.Forms;
using Ch.Cyberduck.Ui.Controller.Threading;
using ch.cyberduck.core;
using ch.cyberduck.core.i18n;

namespace Ch.Cyberduck.Ui.Controller
{
internal class CreateSymlinkController : FileController
{
public CreateSymlinkController(ICreateSymlinkPromptView view, BrowserController browserController)
: base(view, browserController)
{
view.LinkForFile = browserController.SelectedPath.getName();
}

public override Bitmap IconView
{
get { return IconCache.Instance.OverlayIcon("_unknown", "aliasbadge", IconCache.IconSize.Large); }
}

public override void Callback(DialogResult result)
{
if (DialogResult.OK == result && !String.IsNullOrEmpty(View.InputText) &&
!View.InputText.Trim().Equals(string.Empty))
{
BrowserController.background(new CreateSymlinkAction(BrowserController, Workdir, View.InputText));
}
}

private class CreateSymlinkAction : BrowserBackgroundAction
{
private readonly Path _link;
private readonly string _symlink;
private readonly string _target;
private readonly Path _workdir;

public CreateSymlinkAction(BrowserController controller, Path workdir, string symlink)
: base(controller)
{
_workdir = workdir;
_symlink = symlink;
_link = PathFactory.createPath(controller.getSession(),
_workdir.getAbsolute(),
_symlink, AbstractPath.FILE_TYPE);
_target = BrowserController.SelectedPath.getName();
}

public override void run()
{
// Symlink pointing to existing file
_link.symlink(_target);
}

public override void cleanup()
{
if (_symlink.StartsWith("."))
{
BrowserController.ShowHiddenFiles = true;
}
BrowserController.RefreshParentPath(_link);
}

public override string getActivity()
{
return String.Format(Locale.localizedString("Uploading {0}", "Status"), _symlink);
}
}
}
}
24 changes: 24 additions & 0 deletions source/ch/cyberduck/ui/controller/ICreateSymlinkPromptView.cs
@@ -0,0 +1,24 @@
//
// Copyright (c) 2010 Yves Langisch. All rights reserved.
// http://cyberduck.ch/
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// Bug fixes, suggestions and comments should be sent to:
// yves@cyberduck.ch
//
namespace Ch.Cyberduck.Ui.Controller
{
internal interface ICreateSymlinkPromptView : IPromptView
{
string LinkForFile { set; }
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions source/ch/cyberduck/ui/winforms/CreateSymlinkPromptForm.cs
@@ -0,0 +1,43 @@
//
// Copyright (c) 2010-2012 Yves Langisch. All rights reserved.
// http://cyberduck.ch/
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// Bug fixes, suggestions and comments should be sent to:
// yves@cyberduck.ch
//

using System;
using Ch.Cyberduck.Ui.Controller;
using ch.cyberduck.core.i18n;

namespace Ch.Cyberduck.Ui.Winforms
{
public partial class CreateSymlinkPromptForm : PromptForm, ICreateSymlinkPromptView
{
public CreateSymlinkPromptForm()
{
InitializeComponent();
Text = Locale.localizedString("Create new symbolic link", "File");
}

public string LinkForFile
{
set
{
label.Text =
String.Format(Locale.localizedString("Enter the name for the new symbolic link for {0}:", "File"),
value);
}
}
}
}
120 changes: 120 additions & 0 deletions source/ch/cyberduck/ui/winforms/CreateSymlinkPromptForm.resx
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

0 comments on commit beff3a4

Please sign in to comment.