~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, 1840cc1
  • Date: 2012-02-05 10:49:36 UTC
  • mfrom: (10.2.12)
  • Revision ID: package-import@ubuntu.com-20120205104936-f3dutq6lnseokb6d
Tags: 2.8.6.3+dfsg-1
[1840cc1] Imported 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
}