~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/maccore/src/CoreFoundation/CFUrl.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// 
2
2
// CFUrl.cs: Implements the managed CFUrl
3
3
//
4
 
// Authors: Miguel de Icaza
 
4
// Authors:
 
5
//     Miguel de Icaza
 
6
//     Rolf Bjarne Kvinge <rolf@xamarin.com>
5
7
//     
6
8
// Copyright 2009 Novell, Inc
 
9
// Copyright 2012 Xamarin Inc
7
10
//
8
11
// Permission is hereby granted, free of charge, to any person obtaining
9
12
// a copy of this software and associated documentation files (the
37
40
                Windows = 2
38
41
        };
39
42
        
40
 
        public class CFUrl : IDisposable {
 
43
        public class CFUrl : INativeObject, IDisposable {
41
44
                internal IntPtr handle;
42
45
 
43
46
                ~CFUrl ()
87
90
                static public CFUrl FromUrlString (string url, CFUrl baseurl)
88
91
                {
89
92
                        using (var str = new CFString (url)){
90
 
                                IntPtr handle = CFURLCreateWithString (IntPtr.Zero, str.Handle, baseurl != null ? baseurl.Handle : IntPtr.Zero);
91
 
                                if (handle == IntPtr.Zero)
92
 
                                        return null;
93
 
                                return new CFUrl (handle);
 
93
                                return FromStringHandle (str.Handle, baseurl);
94
94
                        }
95
95
                }
96
96
 
 
97
                internal static CFUrl FromStringHandle (IntPtr cfstringHandle, CFUrl baseurl)
 
98
                {
 
99
                        IntPtr handle = CFURLCreateWithString (IntPtr.Zero, cfstringHandle, baseurl != null ? baseurl.Handle : IntPtr.Zero);
 
100
                        if (handle == IntPtr.Zero)
 
101
                                return null;
 
102
                        return new CFUrl (handle);
 
103
                }
 
104
 
97
105
                [DllImport (Constants.CoreFoundationLibrary)]
98
106
                extern static IntPtr CFURLGetString (IntPtr anURL);
99
107
                
103
111
                                return str.ToString ();
104
112
                        }
105
113
                }
 
114
                
 
115
                [DllImport (Constants.CoreFoundationLibrary)]
 
116
                extern static IntPtr CFURLCopyFileSystemPath (IntPtr cfUrl, int style);
 
117
                
 
118
                public string FileSystemPath {
 
119
                        get {
 
120
                                return GetFileSystemPath (handle);
 
121
                        }
 
122
                }
 
123
 
 
124
                static internal string GetFileSystemPath (IntPtr hcfurl)
 
125
                {
 
126
                        using (var str = new CFString (CFURLCopyFileSystemPath (hcfurl, 0), true))
 
127
                                return str.ToString ();
 
128
                }
 
129
 
 
130
                [DllImport (Constants.CoreFoundationLibrary, EntryPoint="CFURLGetTypeID")]
 
131
                public extern static int GetTypeID ();
106
132
        }
107
133
        
108
 
}
 
 
b'\\ No newline at end of file'
 
134
}