]> err.no Git - sope/blob - sope-core/NGExtensions/NGExtensions/NSURL+misc.h
Drop apache 1 build-dependency
[sope] / sope-core / NGExtensions / NGExtensions / NSURL+misc.h
1 /*
2   Copyright (C) 2000-2005 SKYRIX Software AG
3
4   This file is part of SOPE.
5
6   SOPE is free software; you can redistribute it and/or modify it under
7   the terms of the GNU Lesser General Public License as published by the
8   Free Software Foundation; either version 2, or (at your option) any
9   later version.
10
11   SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
12   WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14   License for more details.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with SOPE; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21
22 #ifndef __NGExtensions_NSURL_misc_H__
23 #define __NGExtensions_NSURL_misc_H__
24
25 #import <Foundation/NSObject.h> // required by gstep-base
26 #import <Foundation/NSURL.h>
27 #import <Foundation/NSString.h>
28
29 @interface NSURL(misc)
30
31 /*
32   This method tries to construct the "shortest" path
33   between the two URLs. If the URLs are not in the same
34   namespace, -absoluteString is returned ...
35 */
36 - (NSString *)stringValueRelativeToURL:(NSURL *)_base;
37
38 /*
39   This checks whether protocol, host, login match. That is,
40   checks whether it's possible to build a relative URL to
41   _url (whether self is in the same path namespace).
42 */
43 - (BOOL)isInSameNamespaceWithURL:(NSURL *)_url;
44
45 /* adding fragments and queries to a string ... */
46 - (NSString *)stringByAddingFragmentAndQueryToPath:(NSString *)_path;
47
48 @end
49
50 @interface NSString(URLPathProcessing)
51
52 /* relative path processing (should never return an absolute path) */
53
54 /*
55   eg:                "/a/b/c.html"
56   should resolve to: "c.html"
57     
58   Directories are a bit more difficult, eg:
59     "/a/b/c/"
60   is resolved to
61     "../c/"
62 */
63 - (NSString *)urlPathRelativeToSelf;
64
65 /* this is the same like the absolute path, only without a leading "/" .. */
66 - (NSString *)urlPathRelativeToRoot;
67
68 /*
69   This can be used for URLs in the same namespace. It should
70   never return an absolute path (it only does in error conditions).
71 */
72 - (NSString *)urlPathRelativeToPath:(NSString *)_base;
73
74 @end
75
76 #endif /* __NGExtensions_NSURL_misc_H__ */