Example #1
0
        public static bool TryGetFileSystemEntry(string path, out UnixFileSystemInfo entry)
        {
            Native.Stat stat;
            int         r = Native.Syscall.lstat(path, out stat);

            if (r == -1)
            {
                if (Native.Stdlib.GetLastError() == Native.Errno.ENOENT)
                {
                    entry = new UnixFileInfo(path);
                    return(true);
                }
                entry = null;
                return(false);
            }

            if (IsFileType(stat.st_mode, Native.FilePermissions.S_IFDIR))
            {
                entry = new UnixDirectoryInfo(path, stat);
            }
            else if (IsFileType(stat.st_mode, Native.FilePermissions.S_IFLNK))
            {
                entry = new UnixSymbolicLinkInfo(path, stat);
            }
            else
            {
                entry = new UnixFileInfo(path, stat);
            }

            return(true);
        }
Example #2
0
 /// <summary>
 /// Copies the file at the given path to the server, which could be anywhere from
 /// the local machine to a remote one.
 /// </summary>
 /// <param name="virtualPath">The virtual path.</param>
 public void CopyToServer(VirtualPath virtualPath)
 {
     var fromFullPath = _pathFactory.CreateShadwoFullPath4Write(virtualPath);
       byte[] infoBytes = _serverProxy.Get(new Uri("/BitTorrent/Info"));
       var infoObj = XmlUtil.FromXml<BitTorrentServiceInfo>(
     Encoding.UTF8.GetString(infoBytes));
       if (infoObj.ServerCacheUri.IsLoopback) {
     // Server on the same machine, we copy from file system.
     var relativePath = virtualPath.PathString.Substring(
       virtualPath.PathString.IndexOf(Path.DirectorySeparatorChar, 1));
     var toFullPath = UriUtil.CombinePaths(infoObj.ServerCacheUri.LocalPath,
       new Uri(relativePath, UriKind.Relative));
     IOUtil.PrepareParentDirForPath(toFullPath);
     if (SysEnvironment.OSVersion == OS.Unix) {
       // In case of Unix, we actually use symbolic link instead of copying.
       var symlink = new UnixSymbolicLinkInfo(toFullPath);
       Logger.WriteLineIf(LogLevel.Verbose, _log_props, string.Format(
     "Creating Symlink: {0} -> {1}", toFullPath, fromFullPath.PathString));
       // Linking toPath to fromPath == Copy fromPath to toPath.
       symlink.CreateSymbolicLinkTo(fromFullPath.PathString);
     } else {
       throw new NotImplementedException("Only Unix hosts are currently supported.");
     }
       } else {
     throw new NotImplementedException("Only local machine is currently supported.");
       }
 }
		public override NodeType GetSymbolicLinkTargetType(string path)
		{
			UnixSymbolicLinkInfo obj;

			try
			{
				obj = new UnixSymbolicLinkInfo(path);
			}
			catch (InvalidOperationException)
			{
				/* Not a symbolic link */

				return null;
			}

			try
			{
				if (!obj.IsSymbolicLink)
				{
					return null;
				}

				var retval = obj.GetContents();

				if (retval == null)
				{
					return null;
				}

				var isDirectory = retval.IsDirectory;

				if (isDirectory)
				{
					return NodeType.Directory;
				}

				var isRegularFile = retval.IsRegularFile;

				if (isRegularFile)
				{
					return NodeType.File;
				}

				return null;
			}
			catch (OutOfMemoryException)
			{
				throw;
			}
			catch (StackOverflowException)
			{
				throw;
			}
			catch (Exception)
			{
				return null;
			}
		}
Example #4
0
    public override IEnumerable<Item> Load()
    {
        if (!IsValidConfinementItem (this)) {
            yield break;
        }

        link = new UnixSymbolicLinkInfo (File.FullName);
        if (!link.HasContents) {
            yield break;
        }

        yield return this;
        yield return Item.Resolve (Confinement,
            new FileInfo (link.GetContents ().FullName));
    }
		public override string GetSymbolicLinkTarget(string path)
		{
			UnixSymbolicLinkInfo symbolicLinkInfo;

			try
			{
				symbolicLinkInfo = new UnixSymbolicLinkInfo(path);
			}
			catch (InvalidOperationException)
			{
				/* Not a symbolic link */

				return null;
			}

			string retval = null;

			try
			{

				if (!symbolicLinkInfo.IsSymbolicLink)
				{
					return null;
				}

				retval = symbolicLinkInfo.ContentsPath;

				if (retval != "/" && retval.EndsWith("/"))
				{
					retval = retval.Substring(0, retval.Length - 1);
				}
			}
			catch (OutOfMemoryException)
			{
				throw;
			}
			catch (StackOverflowException)
			{
				throw;
			}
			catch
			{
			}

			return retval;
		}
Example #6
0
 public void cb1(JToken obj, string graph_path, fbdump_params p)
 {
     if (obj.Type == JTokenType.Object)
     {
         JObject obj1 = (JObject)obj;
         string  id   = obj1 ["id"].Value <string> ();
         try {
             string fn = saveto + "/" + id;
             if (System.IO.File.Exists(fn))
             {
                 p.exists++;
             }
             System.IO.FileStream fs = new System.IO.FileStream(fn, p.stop_on_existing ? FileMode.CreateNew : FileMode.Create);
             JsonWriter           w  = new JsonTextWriter(new StreamWriter(fs));
             obj.WriteTo(w);
             w.CloseOutput = true;
             w.Close();
             if (graph_path != null)
             {
                 string n = graph_path.Trim('/').Replace('/', '.');
                 Mono.Unix.UnixSymbolicLinkInfo inf = new Mono.Unix.UnixSymbolicLinkInfo(saveto + "/" + n + "/" + id);
                 inf.CreateSymbolicLinkTo("../" + id);
             }
             foreach (JProperty pr in obj1.Properties())
             {
                 if (p.saveurl.Contains(pr.Name))
                 {
                     saveurl(pr.Value.Value <string> (), id + "." + pr.Name);
                 }
             }
         } catch (Exception ex) {
             Console.WriteLine(ex.Message);
             if (p.stop_on_existing)
             {
                 stop();
             }
         }
     }
 }
		protected override List<Disk> LoadLogicalVolumesInternal() {
			//var files = new string[] { "./FAT16.img", "./FAT32.img", "./NTFS.img"/* "/dev/sdb5" */ };
			/*var disks = new List<Disk>();
			foreach (var file in files) {
				var disk  = new LinLogicalDisk(file);
				disks.Add(disk);
			}
			return disks;*/

			var disks = new List<Disk>();
#if MONO
			foreach (var file in Directory.GetFiles("/dev/disk/by-path")) {
				var actual_path = new UnixSymbolicLinkInfo(file).GetContents().FullName;
				try {
					var disk  = new LinLogicalDisk(actual_path);
					disks.Add(disk);
				} catch (Exception e) {
					Console.Error.WriteLine("Could not read device: " + actual_path);
					//Console.Error.WriteLine(e);
				}
			}
#endif
			return disks;
		}
Example #8
0
        /// <summary>
        /// Depth-first recursive delete, with handling for descendant 
        /// directories open in Windows Explorer.
        /// See http://stackoverflow.com/a/1703799/264822
        /// </summary>
        public static void deleteDirectory(string path)
        {
            Mono.Unix.UnixSymbolicLinkInfo info = new Mono.Unix.UnixSymbolicLinkInfo(path);
            if (info.FileType == FileTypes.Directory)
            {
                foreach (string directory in Directory.GetDirectories(path))
                {
                    deleteDirectory(directory);
                }
            }

            try
            {
                Directory.Delete(path, true);
            }
            catch (IOException)
            {
                Directory.Delete(path, true);
            }
            catch (UnauthorizedAccessException)
            {
                Directory.Delete(path, true);
            }
        }
Example #9
0
        /// <summary>
        /// Depth-first recursive delete, with handling for descendant
        /// directories open in Windows Explorer.
        /// See http://stackoverflow.com/a/1703799/264822
        /// </summary>
        public static void deleteDirectory(string path)
        {
            Mono.Unix.UnixSymbolicLinkInfo info = new Mono.Unix.UnixSymbolicLinkInfo(path);
            if (info.FileType == FileTypes.Directory)
            {
                foreach (string directory in Directory.GetDirectories(path))
                {
                    deleteDirectory(directory);
                }
            }

            try
            {
                Directory.Delete(path, true);
            }
            catch (IOException)
            {
                Directory.Delete(path, true);
            }
            catch (UnauthorizedAccessException)
            {
                Directory.Delete(path, true);
            }
        }
Example #10
0
        /// <summary>
        /// Checks whether a file is a Unix symbolic link.
        /// </summary>
        /// <param name="path">The path of the file to check.</param>
        /// <param name="target">Returns the target the symbolic link points to if it exists.</param>
        /// <returns><c>true</c> if <paramref name="path"/> points to a symbolic link; <c>false</c> otherwise.</returns>
        /// <exception cref="InvalidOperationException">The underlying Unix subsystem failed to process the request (e.g. because of insufficient rights).</exception>
        /// <exception cref="UnixIOException">The underlying Unix subsystem failed to process the request (e.g. because of insufficient rights).</exception>
        public static bool IsSymlink([NotNull, Localizable(false)] string path, out string target)
        {
            #region Sanity checks
            if (string.IsNullOrEmpty(path)) throw new ArgumentNullException(nameof(path));
            #endregion

            bool result = IsSymlink(path);
            if (result)
            {
                var symlinkInfo = new UnixSymbolicLinkInfo(path);
                target = symlinkInfo.ContentsPath;
            }
            else target = null;
            return result;
        }
Example #11
0
        /// <summary>
        /// This thread is the main thread that checks for devices being added to or removed from the system.
        /// </summary>
        private void StorageDeviceDetectionThread()
        {
            int      errorCount    = 0;
            DateTime lastErrorTime = new DateTime(0);

            while (IsStarted && !IsStopping)
            {
                try
                {
                    // Determine all current available devices by UUID for those that are not in ignore list
                    string[]      allDevices     = Directory.GetFiles("/dev/disk/by-uuid");
                    List <string> allDeviceNames = new List <string>();
                    foreach (string uuidPath in allDevices)
                    {
                        try
                        {
                            // Get the real device from the symbolic link
                            string device = uuidPath;
                            Mono.Unix.UnixSymbolicLinkInfo symLink = new Mono.Unix.UnixSymbolicLinkInfo(uuidPath);
                            if (symLink.HasContents)
                            {
                                device = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(device), symLink.ContentsPath));
                            }
                            allDeviceNames.Add(device);

                            // If this device is on ignore list, already mounted or already failed skip it
                            if ((_devicesToIgnore.Contains(device)) || (_mountedDevices.ContainsKey(device)))
                            {
                                continue;
                            }

                            // Mount the device
                            string uuid = Path.GetFileName(uuidPath);
                            if (!Mount(device, _mountPrefix + "/" + uuid))
                            {
                                _devicesToIgnore.Add(device);
                            }
                            else
                            {
                                _mountedDevices.Add(device, uuid);
                                if (DeviceMounted != null)
                                {
                                    DeviceMounted(this, new MountedDeviceEventArgs(new MountedDevice(device, _mountPrefix + "/" + uuid, uuid)));
                                }
                            }
                        }
                        catch
                        {
                        }
                    }

                    // Determine removed devices and unmount plus update dictionaries
                    Dictionary <string, string> allMountedDevices = GetMountedDevices();
                    List <string> removedDevices = new List <string>();
                    foreach (KeyValuePair <string, string> mountedDevice in _mountedDevices)
                    {
                        if ((!allMountedDevices.ContainsKey(mountedDevice.Key)) || (!File.Exists(mountedDevice.Key)))
                        {
                            removedDevices.Add(mountedDevice.Key);
                        }
                    }
                    foreach (string failedDevice in _devicesToIgnore)
                    {
                        if ((!allDeviceNames.Contains(failedDevice)) || (!File.Exists(failedDevice)))
                        {
                            removedDevices.Add(failedDevice);
                        }
                    }
                    foreach (string removedDevice in removedDevices)
                    {
                        // Remove from mappings
                        if (_devicesToIgnore.Contains(removedDevice))
                        {
                            _devicesToIgnore.Remove(removedDevice);
                        }
                        if (_mountedDevices.ContainsKey(removedDevice))
                        {
                            _mountedDevices.Remove(removedDevice);
                        }

                        // Attempt to unmount
                        string mountPath = allMountedDevices.ContainsKey(removedDevice) ? allMountedDevices[removedDevice] : null;
                        Unmount(removedDevice, mountPath);
                        if (DeviceUnmounted != null)
                        {
                            string uuid = null;
                            if ((mountPath != null) && (mountPath.StartsWith(_mountPrefix)))
                            {
                                uuid = mountPath.Substring(_mountPrefix.Length + 1);
                            }
                            DeviceUnmounted(this, new MountedDeviceEventArgs(new MountedDevice(removedDevice, _mountPrefix + uuid, uuid)));
                        }
                    }

                    // Wait for next loop
                    Thread.Sleep(500);
                }
                catch
                {
                    if (DateTime.UtcNow.Subtract(lastErrorTime).TotalSeconds > 30)
                    {
                        errorCount = 0;
                    }
                    errorCount++;
                    if (errorCount >= 5)
                    {
                        throw;
                    }
                    lastErrorTime = DateTime.UtcNow;
                }
            }

            _storageDeviceDetectionThread = null;
        }
Example #12
0
        public static string ResolveSymbolicLink(string path)
        {
            if (string.IsNullOrEmpty (path))
                return path;

            if (Path.DirectorySeparatorChar == '\\')
                return Path.GetFullPath (path);

            try {
                var alreadyVisted = new HashSet<string> ();

                while (true) {
                    if (alreadyVisted.Contains (path))
                        return string.Empty;

                    alreadyVisted.Add (path);

                    var linkInfo = new UnixSymbolicLinkInfo (path);
                    if (linkInfo.IsSymbolicLink && linkInfo.HasContents) {
                        string contentsPath = linkInfo.ContentsPath;

                        if (!Path.IsPathRooted (contentsPath))
                            path = Path.Combine (Path.GetDirectoryName (path), contentsPath);
                        else
                            path = contentsPath;

                        path = ResolveFullPath (path);
                        continue;
                    }

                    path = Path.Combine (ResolveSymbolicLink (Path.GetDirectoryName (path)), Path.GetFileName (path));

                    return ResolveFullPath (path);
                }
            } catch {
                return path;
            }
        }
Example #13
0
 public override bool RenameTo(FilePath path, string name)
 {
     var symlink = GetUnixFileInfo (path) as UnixSymbolicLinkInfo;
     if (symlink != null) {
         var newFile = new UnixSymbolicLinkInfo (name);
         newFile.CreateSymbolicLinkTo (symlink.ContentsPath);
         return true;
     } else {
         return base.RenameTo (path, name);
     }
 }
Example #14
0
        /// <summary>
        /// Gets all currently mounted devices on the system.
        /// </summary>
        /// <returns>
        /// A dictionary keying the physical device to its mount path.
        /// </returns>
        private Dictionary <string, string> GetMountedDevices()
        {
            // Read the MTab file initially and load all data
            string[] mtabLines = File.ReadAllLines("/proc/mounts");
            Dictionary <string, string> returnValue = new Dictionary <string, string>();

            foreach (string line in mtabLines)
            {
                string[] parts         = line.Split(new char[] { ' ' });
                string   device        = string.Empty;
                string   mountPath     = string.Empty;
                int      startIndex    = 0;
                bool     parsingDevice = true;
                for (int i = 1; i < parts.Length; i++)
                {
                    // If previous string ended in / we continue
                    if (parts[i - 1].EndsWith("\\"))
                    {
                        continue;
                    }

                    // The previous one didn't end with a / so it's a completed part
                    if (parsingDevice)
                    {
                        // Get the device
                        for (int j = startIndex; j < i; j++)
                        {
                            device += (device == string.Empty ? string.Empty : " ") + parts[j];
                        }
                        startIndex = i;

                        // If the device does not start with a "/" we assume it's not a real path
                        if (!device.StartsWith("/"))
                        {
                            break;
                        }

                        // Move on to parsing the mount path
                        parsingDevice = false;
                    }
                    else
                    {
                        for (int j = startIndex; j < i; j++)
                        {
                            mountPath += (mountPath == string.Empty ? string.Empty : " ") + parts[j];
                        }
                        break;
                    }
                }

                // Continue if we don't have a mount path and device
                if ((string.IsNullOrEmpty(device)) || (string.IsNullOrEmpty(mountPath)))
                {
                    continue;
                }

                // If the device name is a symbolic link attempt to convert to its real one
                if (File.Exists(device))
                {
                    Mono.Unix.UnixSymbolicLinkInfo symLink = new Mono.Unix.UnixSymbolicLinkInfo(device);
                    if (symLink.HasContents)
                    {
                        device = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(device), symLink.ContentsPath));
                    }
                }

                // Add to return value
                returnValue.Add(device, mountPath);
            }

            // Return the results
            return(returnValue);
        }
		protected override BuildResult Build (IProgressMonitor monitor, SolutionEntityItem item, ConfigurationSelector configuration)
		{
			var proj = item as MonoMacProject;
			if (proj == null || proj.CompileTarget != CompileTarget.Exe)
				return base.Build (monitor, item, configuration);
			
			var conf = (MonoMacProjectConfiguration) configuration.GetConfiguration (item);
			var resDir = conf.AppDirectory.Combine ("Contents", "Resources");
			var appDir = conf.AppDirectory;
			
			var res = base.Build (monitor, item, configuration);
			if (res.ErrorCount > 0)
				return res;
			
			//copy exe, mdb, refs, copy-to-output, Content files to Resources
			var filesToCopy = GetCopyFiles (proj, configuration, conf).Where (NeedsBuilding).ToList ();
			if (filesToCopy.Count > 0) {
				monitor.BeginTask ("Copying resource files to app bundle", filesToCopy.Count);
				foreach (var f in filesToCopy) {
					f.EnsureOutputDirectory ();
					File.Copy (f.Input, f.Output, true);
					monitor.Log.WriteLine ("Copied {0}", f.Output.ToRelative (appDir));
					monitor.Step (1);
				}
				monitor.EndTask ();
			}
			
			//FIXME: only do this check if there are actually xib files
			if (!Platform.IsMac) {
				res.AddWarning ("Cannot compile xib files on non-Mac platforms");
			} else {
				//Interface Builder files
				if (res.Append (CompileXibFiles (monitor, proj.Files, resDir)).ErrorCount > 0)
					return res;
			}
			
			//info.plist
			var plistOut = conf.AppDirectory.Combine ("Contents", "Info.plist");
			var appInfoIn = proj.Files.GetFile (proj.BaseDirectory.Combine ("Info.plist"));
			if (new FilePair (proj.FileName, plistOut).NeedsBuilding () ||
			    	(appInfoIn != null && new FilePair (appInfoIn.FilePath, plistOut).NeedsBuilding ()))
				if (res.Append (MergeInfoPlist (monitor, proj, conf, appInfoIn, plistOut)).ErrorCount > 0)
					return res;
			
			if (Platform.IsWindows) {
				res.AddWarning ("Cannot create app bundle on Windows");
			} else {	
				//launch script
				var macOSDir = appDir.Combine ("Contents", "MacOS");
				CopyExecutableFile (AddinManager.CurrentAddin.GetFilePath ("MonoMacLaunchScript.sh"), conf.LaunchScript);
				CopyExecutableFile (AddinManager.CurrentAddin.GetFilePath ("mono-version-check"),
					macOSDir.Combine ("mono-version-check"));
				
				var si = new UnixSymbolicLinkInfo (appDir.Combine (conf.AppName));
				if (!si.Exists)
					si.CreateSymbolicLinkTo ("/Library/Frameworks/Mono.framework/Versions/Current/bin/mono");
			}
			
			//pkginfo
			var pkgInfo = conf.AppDirectory.Combine ("Contents", "PkgInfo");
			if (!File.Exists (pkgInfo))
				using (var f = File.OpenWrite (pkgInfo))
					f.Write (new byte [] { 0X41, 0X50, 0X50, 0X4C, 0x3f, 0x3f, 0x3f, 0x3f}, 0, 8); // "APPL???"
			
			return res;
		}
Example #16
0
        private UnixFileSystemInfo TraverseSymlink(UnixFileSystemInfo info)
        {
            lock (visited_symlinks) {
                visited_symlinks.Clear ();
                while (info.IsSymbolicLink) {
                    if (visited_symlinks.Contains (info.FullName)) {
                        return null;
                    }
                    visited_symlinks.Add (info.FullName);
                    var target = new UnixSymbolicLinkInfo (info.FullName).GetContents ();
                    if (info.FullName.StartsWith (target.FullName)) {
                        return null;
                    }
                    if (!target.Exists) {
                        return null;
                    }
                    info = target;
                }

                return info;
            }
        }
Example #17
0
    public void Setup(UnixFileSystemInfo u)
    {
        FullName = u.FullName;
        Name = u.Name;
        LCName = Name.ToLower ();

        Owner = Helpers.OwnerName(u);
        Group = Helpers.GroupName(u);

        LastModified = Helpers.LastModified(u);
        LastFileChange = Helpers.LastChange(FullName);
        Permissions = Helpers.FilePermissions(u);
        FileType = Helpers.FileType(u);

        IsDirectory = FileType == FileTypes.Directory;
        if (FileType == FileTypes.SymbolicLink) {
          LinkTarget = Helpers.ReadLink(FullName);
          var lt = new UnixSymbolicLinkInfo(LinkTarget);
          IsDirectory = Helpers.FileExists(LinkTarget) && Helpers.FileType(lt) == FileTypes.Directory;
        }

        Suffix = IsDirectory ? "" : Helpers.Extname(Name).ToLower();

        Size = Helpers.FileSize(u);

        if (!IsDirectory) {
          Count = 1;
          SubTreeSize = Size;
          SubTreeCount = 1;
          Complete = true;
          FilePassDone = true;
        } else {
          Count = 0;
          Entries = new List<FSEntry> ();
        }
    }
Example #18
0
	public void cb1 (JToken obj, string graph_path, fbdump_params p)
	{
		if (obj.Type == JTokenType.Object) {
			JObject obj1 = (JObject)obj;
			string id = obj1 ["id"].Value<string> ();
			try {
				string fn = saveto + "/" + id;
				if (System.IO.File.Exists (fn))
					p.exists++;
				System.IO.FileStream fs = new System.IO.FileStream (fn, p.stop_on_existing ? FileMode.CreateNew : FileMode.Create);
				JsonWriter w = new JsonTextWriter (new StreamWriter (fs));
				obj.WriteTo (w);
				w.CloseOutput = true;
				w.Close ();
				if (graph_path != null) {
					string n = graph_path.Trim ('/').Replace ('/', '.');
					Mono.Unix.UnixSymbolicLinkInfo inf = new Mono.Unix.UnixSymbolicLinkInfo (saveto + "/" + n + "/" + id);
					inf.CreateSymbolicLinkTo ("../" + id);
				}
				foreach (JProperty pr in obj1.Properties()) {
					if (p.saveurl.Contains (pr.Name)) {
						saveurl (pr.Value.Value<string> (), id + "." + pr.Name);
					}
				}
			} catch (Exception ex) {
				Console.WriteLine (ex.Message);
				if (p.stop_on_existing) {
					stop ();
				}
			}
		}
	}
Example #19
0
		public bool RenameTo (string name)
		{
			try {
				if (RunningOnLinux) {
					var symlink = UnixFileInfo.GetFileSystemEntry (path) as UnixSymbolicLinkInfo;
					if (symlink != null) {
						var newFile = new UnixSymbolicLinkInfo (name);
						newFile.CreateSymbolicLinkTo (symlink.ContentsPath);
					}
				}

				File.Move (path, name);
				return true;
			} catch {
				return false;
			}
		}
		public static bool TryGetFileSystemEntry (string path, out UnixFileSystemInfo entry)
		{
			Native.Stat stat;
			int r = Native.Syscall.lstat (path, out stat);
			if (r == -1) {
				if (Native.Stdlib.GetLastError() == Native.Errno.ENOENT) {
					entry = new UnixFileInfo (path);
					return true;
				}
				entry = null;
				return false;
			}

			if (IsFileType (stat.st_mode, Native.FilePermissions.S_IFDIR))
				entry = new UnixDirectoryInfo (path, stat);
			else if (IsFileType (stat.st_mode, Native.FilePermissions.S_IFLNK))
				entry = new UnixSymbolicLinkInfo (path, stat);
			else
				entry = new UnixFileInfo (path, stat);

			return true;
		}
Example #21
0
		string GetTargetFile (string file)
		{
			if (!Platform.IsWindows) {
				try {
					UnixSymbolicLinkInfo fi = new UnixSymbolicLinkInfo (file);
					if (fi.IsSymbolicLink)
						return fi.ContentsPath;
				} catch {
				}
			}
			return file;
		}
Example #22
0
		public override bool RenameTo (FilePath path, string name)
		{
			var symlink = GetUnixFileInfo (path) as UnixSymbolicLinkInfo;
			if (symlink != null) {
				var newFile = new UnixSymbolicLinkInfo (name);
				newFile.CreateSymbolicLinkTo (symlink.ContentsPath);
				return true;
			} else {
				// This call replaces the file if it already exists.
				// File.Move throws an exception if dest already exists
				return Mono.Unix.Native.Stdlib.rename (path, name) == 0;
			}
		}