| 1 |
// SubversionSharp, a wrapper library around the Subversion client API |
|---|
| 2 |
#region Copyright (C) 2004 SOFTEC sa. |
|---|
| 3 |
// |
|---|
| 4 |
// This library is free software; you can redistribute it and/or |
|---|
| 5 |
// modify it under the terms of the GNU Lesser General Public |
|---|
| 6 |
// License as published by the Free Software Foundation; either |
|---|
| 7 |
// version 2.1 of the License, or (at your option) any later version. |
|---|
| 8 |
// |
|---|
| 9 |
// This library is distributed in the hope that it will be useful, |
|---|
| 10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 12 |
// Lesser General Public License for more details. |
|---|
| 13 |
// |
|---|
| 14 |
// You should have received a copy of the GNU Lesser General Public |
|---|
| 15 |
// License along with this library; if not, write to the Free Software |
|---|
| 16 |
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 17 |
// |
|---|
| 18 |
// Sources, support options and lastest version of the complete library |
|---|
| 19 |
// is available from: |
|---|
| 20 |
// http://www.softec.st/SubversionSharp |
|---|
| 21 |
// |
|---|
| 22 |
// |
|---|
| 23 |
// Initial authors : |
|---|
| 24 |
// Denis Gervalle |
|---|
| 25 |
// Olivier Desaive |
|---|
| 26 |
#endregion |
|---|
| 27 |
// |
|---|
| 28 |
using System; |
|---|
| 29 |
using System.Diagnostics; |
|---|
| 30 |
using System.Runtime.InteropServices; |
|---|
| 31 |
using Softec.AprSharp; |
|---|
| 32 |
|
|---|
| 33 |
namespace Softec.SubversionSharp |
|---|
| 34 |
{ |
|---|
| 35 |
public unsafe class SvnDirEnt : IAprUnmanaged |
|---|
| 36 |
{ |
|---|
| 37 |
private svn_dirent_t *mDirEnt; |
|---|
| 38 |
|
|---|
| 39 |
#if WIN32 |
|---|
| 40 |
[StructLayout( LayoutKind.Sequential, Pack=8 )] |
|---|
| 41 |
#else |
|---|
| 42 |
[StructLayout( LayoutKind.Sequential, Pack=4 )] |
|---|
| 43 |
#endif |
|---|
| 44 |
private struct svn_dirent_t |
|---|
| 45 |
{ |
|---|
| 46 |
public int kind; |
|---|
| 47 |
public long size; |
|---|
| 48 |
public int has_props; |
|---|
| 49 |
public int created_rev; |
|---|
| 50 |
public long time; |
|---|
| 51 |
public IntPtr last_author; |
|---|
| 52 |
} |
|---|
| 53 |
|
|---|
| 54 |
#region Generic embedding functions of an IntPtr |
|---|
| 55 |
private SvnDirEnt(svn_dirent_t *ptr) |
|---|
| 56 |
{ |
|---|
| 57 |
mDirEnt = ptr; |
|---|
| 58 |
} |
|---|
| 59 |
|
|---|
| 60 |
public SvnDirEnt(IntPtr ptr) |
|---|
| 61 |
{ |
|---|
| 62 |
mDirEnt = (svn_dirent_t *) ptr.ToPointer(); |
|---|
| 63 |
} |
|---|
| 64 |
|
|---|
| 65 |
public bool IsNull |
|---|
| 66 |
{ |
|---|
| 67 |
get |
|---|
| 68 |
{ |
|---|
| 69 |
return( mDirEnt == null ); |
|---|
| 70 |
} |
|---|
| 71 |
} |
|---|
| 72 |
|
|---|
| 73 |
private void CheckPtr() |
|---|
| 74 |
{ |
|---|
| 75 |
if( IsNull ) |
|---|
| 76 |
throw new AprNullReferenceException(); |
|---|
| 77 |
} |
|---|
| 78 |
|
|---|
| 79 |
public void ClearPtr() |
|---|
| 80 |
{ |
|---|
| 81 |
mDirEnt = null; |
|---|
| 82 |
} |
|---|
| 83 |
|
|---|
| 84 |
public IntPtr ToIntPtr() |
|---|
| 85 |
{ |
|---|
| 86 |
return new IntPtr(mDirEnt); |
|---|
| 87 |
} |
|---|
| 88 |
|
|---|
| 89 |
public bool ReferenceEquals(IAprUnmanaged obj) |
|---|
| 90 |
{ |
|---|
| 91 |
return(obj.ToIntPtr() == ToIntPtr()); |
|---|
| 92 |
} |
|---|
| 93 |
|
|---|
| 94 |
public static implicit operator IntPtr(SvnDirEnt entry) |
|---|
| 95 |
{ |
|---|
| 96 |
return new IntPtr(entry.mDirEnt); |
|---|
| 97 |
} |
|---|
| 98 |
|
|---|
| 99 |
public static implicit operator SvnDirEnt(IntPtr ptr) |
|---|
| 100 |
{ |
|---|
| 101 |
return new SvnDirEnt(ptr); |
|---|
| 102 |
} |
|---|
| 103 |
|
|---|
| 104 |
public override string ToString() |
|---|
| 105 |
{ |
|---|
| 106 |
return("[svn_dirent_t:"+(new IntPtr(mDirEnt)).ToInt32().ToString("X")+"]"); |
|---|
| 107 |
} |
|---|
| 108 |
#endregion |
|---|
| 109 |
|
|---|
| 110 |
#region Properties wrappers |
|---|
| 111 |
public Svn.NodeKind Kind |
|---|
| 112 |
{ |
|---|
| 113 |
get |
|---|
| 114 |
{ |
|---|
| 115 |
CheckPtr(); |
|---|
| 116 |
return((Svn.NodeKind)mDirEnt->kind); |
|---|
| 117 |
} |
|---|
| 118 |
} |
|---|
| 119 |
|
|---|
| 120 |
public long Size |
|---|
| 121 |
{ |
|---|
| 122 |
get |
|---|
| 123 |
{ |
|---|
| 124 |
CheckPtr(); |
|---|
| 125 |
return(mDirEnt->size); |
|---|
| 126 |
} |
|---|
| 127 |
} |
|---|
| 128 |
|
|---|
| 129 |
public bool HasProps |
|---|
| 130 |
{ |
|---|
| 131 |
get |
|---|
| 132 |
{ |
|---|
| 133 |
CheckPtr(); |
|---|
| 134 |
return(mDirEnt->has_props != 0); |
|---|
| 135 |
} |
|---|
| 136 |
} |
|---|
| 137 |
|
|---|
| 138 |
public int CreationRevision |
|---|
| 139 |
{ |
|---|
| 140 |
get |
|---|
| 141 |
{ |
|---|
| 142 |
CheckPtr(); |
|---|
| 143 |
return(mDirEnt->created_rev); |
|---|
| 144 |
} |
|---|
| 145 |
} |
|---|
| 146 |
|
|---|
| 147 |
public long Time |
|---|
| 148 |
{ |
|---|
| 149 |
get |
|---|
| 150 |
{ |
|---|
| 151 |
CheckPtr(); |
|---|
| 152 |
return(mDirEnt->time); |
|---|
| 153 |
} |
|---|
| 154 |
} |
|---|
| 155 |
|
|---|
| 156 |
public SvnData LastAuthor |
|---|
| 157 |
{ |
|---|
| 158 |
get |
|---|
| 159 |
{ |
|---|
| 160 |
CheckPtr(); |
|---|
| 161 |
return(mDirEnt->last_author); |
|---|
| 162 |
} |
|---|
| 163 |
} |
|---|
| 164 |
#endregion |
|---|
| 165 |
} |
|---|
| 166 |
} |
|---|