~ubuntu-branches/ubuntu/saucy/monodevelop/saucy-proposed

« back to all changes in this revision

Viewing changes to src/core/MonoDevelop.Core/MonoDevelop.Core.FileSystem/UnixFileSystemExtension.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2012-02-05 10:49:36 UTC
  • mto: (10.3.1)
  • mto: This revision was merged to the branch mainline in revision 25.
  • Revision ID: package-import@ubuntu.com-20120205104936-4ujoylapu24cquuo
Tags: upstream-2.8.6.3+dfsg
ImportĀ upstreamĀ versionĀ 2.8.6.3+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
{
33
33
        class UnixFileSystemExtension : DefaultFileSystemExtension
34
34
        {
 
35
                const int PATHMAX = 4096 + 1;
 
36
                
35
37
                [DllImport ("libc")]
36
 
                static extern string realpath (string path, IntPtr buffer);
 
38
                static extern IntPtr realpath (string path, IntPtr buffer);
37
39
                
38
40
                public override FilePath ResolveFullPath (FilePath path)
39
41
                {
40
 
                        // Handle symlinks
41
 
                        return realpath (path, IntPtr.Zero);
 
42
                        IntPtr buffer = IntPtr.Zero;
 
43
                        try {
 
44
                                buffer = Marshal.AllocHGlobal (PATHMAX);
 
45
                                var result = realpath (path, buffer);
 
46
                                return result == IntPtr.Zero ? "" : Marshal.PtrToStringAuto (buffer);
 
47
                        } finally {
 
48
                                if (buffer != IntPtr.Zero)
 
49
                                        Marshal.FreeHGlobal (buffer);
 
50
                        }
42
51
                }
43
52
        }
44
53
}