lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [Lucene.Net] svn commit: r1162569 - in /incubator/lucene.net/branches/Lucene.Net_2_9_4g: build/vs2010/test/ src/contrib/IsolatedStorage/ test/contrib/IsolatedStorage/
Date Sun, 28 Aug 2011 18:32:24 GMT
Author: digy
Date: Sun Aug 28 18:32:24 2011
New Revision: 1162569

URL: http://svn.apache.org/viewvc?rev=1162569&view=rev
Log:
[LUCENENET-424] A working copy for IsolatedStorageDirectory (not tested for WP7)

Added:
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/build/vs2010/test/Contrib.IsolatedStorage.Test.sln
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/IsolatedStorage/IsolatedStorageIndexInput.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/IsolatedStorage/IsolatedStorageIndexOutput.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/IsolatedStorage/IsolatedStorageLock.cs
Modified:
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/IsolatedStorage/Contrib.IsolatedStorage.csproj
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/IsolatedStorage/IsolatedStorageDirectory.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/IsolatedStorage/IsolatedStorageInputStream.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/IsolatedStorage/IsolatedStorageOutputStream.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/contrib/IsolatedStorage/Contrib.IsolatedStorage.Test.csproj

Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/build/vs2010/test/Contrib.IsolatedStorage.Test.sln
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/build/vs2010/test/Contrib.IsolatedStorage.Test.sln?rev=1162569&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/build/vs2010/test/Contrib.IsolatedStorage.Test.sln
(added)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/build/vs2010/test/Contrib.IsolatedStorage.Test.sln
Sun Aug 28 18:32:24 2011
@@ -0,0 +1,32 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contrib.IsolatedStorage.Test", "..\..\..\test\contrib\IsolatedStorage\Contrib.IsolatedStorage.Test.csproj",
"{0B1E98BF-C6B4-4C4C-8E5A-6CC72BAF208E}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lucene.Net", "..\..\..\src\core\Lucene.Net.csproj",
"{5D4AD9BE-1FFB-41AB-9943-25737971BF57}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contrib.IsolatedStorage", "..\..\..\src\contrib\IsolatedStorage\Contrib.IsolatedStorage.csproj",
"{7AAC492D-1526-463A-8AAE-4433577E0950}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{0B1E98BF-C6B4-4C4C-8E5A-6CC72BAF208E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{0B1E98BF-C6B4-4C4C-8E5A-6CC72BAF208E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{0B1E98BF-C6B4-4C4C-8E5A-6CC72BAF208E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{0B1E98BF-C6B4-4C4C-8E5A-6CC72BAF208E}.Release|Any CPU.Build.0 = Release|Any CPU
+		{5D4AD9BE-1FFB-41AB-9943-25737971BF57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{5D4AD9BE-1FFB-41AB-9943-25737971BF57}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{5D4AD9BE-1FFB-41AB-9943-25737971BF57}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{5D4AD9BE-1FFB-41AB-9943-25737971BF57}.Release|Any CPU.Build.0 = Release|Any CPU
+		{7AAC492D-1526-463A-8AAE-4433577E0950}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{7AAC492D-1526-463A-8AAE-4433577E0950}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{7AAC492D-1526-463A-8AAE-4433577E0950}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{7AAC492D-1526-463A-8AAE-4433577E0950}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/IsolatedStorage/Contrib.IsolatedStorage.csproj
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/IsolatedStorage/Contrib.IsolatedStorage.csproj?rev=1162569&r1=1162568&r2=1162569&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/IsolatedStorage/Contrib.IsolatedStorage.csproj
(original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/IsolatedStorage/Contrib.IsolatedStorage.csproj
Sun Aug 28 18:32:24 2011
@@ -35,8 +35,9 @@
   </ItemGroup>
   <ItemGroup>
     <Compile Include="IsolatedStorageDirectory.cs" />
-    <Compile Include="IsolatedStorageInputStream.cs" />
-    <Compile Include="IsolatedStorageOutputStream.cs" />
+    <Compile Include="IsolatedStorageIndexInput.cs" />
+    <Compile Include="IsolatedStorageLock.cs" />
+    <Compile Include="IsolatedStorageIndexOutput.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
   </ItemGroup>
   <ItemGroup>

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/IsolatedStorage/IsolatedStorageDirectory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/IsolatedStorage/IsolatedStorageDirectory.cs?rev=1162569&r1=1162568&r2=1162569&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/IsolatedStorage/IsolatedStorageDirectory.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/IsolatedStorage/IsolatedStorageDirectory.cs
Sun Aug 28 18:32:24 2011
@@ -22,263 +22,128 @@ using System.IO.IsolatedStorage;
 namespace Lucene.Net.Store
 {
 
-    public class IsolatedStorageDirectory : Directory
+    public class IsolatedStorageDirectory : Lucene.Net.Store.Directory
     {
-        private IsolatedStorageFile IsoDirectory = null;
-        private string IsoDirectoryPath = null;
+        System.IO.IsolatedStorage.IsolatedStorageFile _is = null;
+        string _dirName;
 
-        /// <summary>
-        /// Create a new instance of the isolated store for this user, domain, and assembly
-        /// </summary>
-        /// <param name="path">Path within the store for the Lucene indexs</param>
-        public IsolatedStorageDirectory(string path) : this(path, null)
+        public IsolatedStorageDirectory(System.IO.DirectoryInfo dInfo)
+            : this(dInfo.FullName)
         {
         }
 
-        /// <summary>
-        /// Create a new instance of the isolated store for this user, domain, and assembly
-        /// </summary>
-        /// <param name="path">Path within the store for the Lucene indexs</param>
-        /// <param name="lockFactory">Not Implimented</param>
-        /// TODO: Impliment lockFactory
-        public IsolatedStorageDirectory(string path, LockFactory lockFactory)
-        {
-            IsoDirectory = IsolatedStorageFile.GetUserStoreForApplication();
-            
-            if (!IsoDirectory.DirectoryExists(path))
-            {
-                throw new NoSuchDirectoryException(String.Format("{0} exists but is not a
folder", path));
-            }
+        public IsolatedStorageDirectory(string dirName)
+        {
+            _is = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForAssembly();
 
-            IsoDirectoryPath = path.TrimEnd('/');
+            _dirName = dirName;
+            _is.CreateDirectory(dirName);
         }
 
-        /// <summary>
-        /// Initializes the directory to create a new file with the given name.
-        /// This method should be used in {@link #createOutput}. 
-        /// </summary>
-        protected internal void InitOutput(string name)
+        public static void Remove(string dirName)
         {
-            var isoFile = GetIsoStoragePath(name);
+            var dir = new IsolatedStorageDirectory(dirName);
+            dir.Remove();
+            dir.Close();
+        }
 
-            if (IsoDirectory.FileExists(isoFile))
+        public void Remove()
+        {
+            foreach (var f in ListAll())
             {
-                IsoDirectory.DeleteFile(isoFile);
+                for (int i = 0; i < 5; i++)
+                {
+                    try
+                    {
+                        _is.DeleteFile(Path.Combine(_dirName, f));
+                        break;
+                    }
+                    catch
+                    {
+                        System.Threading.Thread.Sleep(100);
+                    }
+                }
             }
-        }
 
-        /// <summary>
-        /// Lists all files (not subdirectories) in the directory.
-        /// </summary>
-        public String[] ListAll(string dir)
-        {
-            if (!IsoDirectory.DirectoryExists(dir))
+            try
             {
-                throw new NoSuchDirectoryException(String.Format("Directory '{0}' does not
exist", dir));
+                _is.DeleteDirectory(_dirName);
             }
+            catch { }
+        }
 
-            return IsoDirectory.GetFileNames();
+        public override Lock MakeLock(string name)
+        {
+            return new IsolatedStorageLock(_is, Path.Combine(_dirName, name));
         }
 
-        /// <summary>
-        /// Lists all files (not subdirectories) in the directory.
-        /// </summary>
-        public override String[] ListAll()
+        public override string[] ListAll()
         {
-            return ListAll(IsoDirectoryPath);
+            return _is.GetFileNames(Path.Combine(_dirName, "*"));
+        }
+
+        public override string[] List()
+        {
+            return ListAll();
         }
 
-        /// <summary>
-        /// Returns true iff a file with the given name exists. 
-        /// </summary>
         public override bool FileExists(string name)
         {
-            return IsoDirectory.FileExists(GetIsoStoragePath(name));
+            return _is.FileExists(Path.Combine(_dirName, name));
         }
 
-        /// <summary>
-        /// Returns the time the named file was last modified. 
-        /// </summary>
         public override long FileModified(string name)
         {
-            var file = GetIsoStoragePath(name);
-
-            if (IsoDirectory.FileExists(file))
-            {
-                // {{LUCENENET-353}}
-                return (long) IsoDirectory.GetLastWriteTime(file)
-                    .ToUniversalTime()
-                    .Subtract(new DateTime(1970, 1, 1, 0, 0, 0))
-                    .TotalMilliseconds;
-            }
-
-            throw new FileNotFoundException(name + "not found");
+            return GetDate(_is.GetLastWriteTime(Path.Combine(_dirName, name)).LocalDateTime);
         }
 
-        /// <summary>
-        /// Set the modified time of an existing file to now.
-        /// </summary>
         public override void TouchFile(string name)
         {
-            var file = GetIsoStoragePath(name);
-
-            var f = new IsolatedStorageFileStream(file, FileMode.Append);
-            f.Close(); // TODO: Verify that this updates the modified time of the file
+            _is.OpenFile(name, FileMode.OpenOrCreate).Close();
         }
 
-        /// <summary>
-        /// Returns the length in bytes of a file in the directory
-        /// </summary>
-        public override long FileLength(string name)
+        public override void DeleteFile(string name)
         {
-            var file = GetIsoStoragePath(name);
-            var isoFile = new IsolatedStorageFileStream(file, FileMode.Open);
-            return isoFile.Length;
+            _is.DeleteFile(Path.Combine(_dirName, name));
         }
 
-        /// <summary>
-        /// Removes an existing file in the directory. 
-        /// </summary>
-        public override void DeleteFile(string name)
+        public override void RenameFile(string from, string to)
         {
-            var file = GetIsoStoragePath(name);
-            IsoDirectory.DeleteFile(file);
+            _is.MoveFile(Path.Combine(_dirName, from), Path.Combine(_dirName, to));
         }
 
-        /// <summary>
-        /// Sync the file back to IsolatedStorage
-        /// </summary>
-        /// <param name="name"></param>
-        public override void Sync(string name)
+        public override long FileLength(string name)
         {
-            var fileName = GetIsoStoragePath(name);
-            var success = false;
-            var retryCount = 0;
-
-            IOException exc = null;
-
-            while (!success && retryCount < 5)
+            using (var f = _is.OpenFile(Path.Combine(_dirName, name), FileMode.Open))
             {
-                retryCount++;
-                IsolatedStorageFileStream file = null;
-
-                try
-                {
-                    try
-                    {
-                        file = new IsolatedStorageFileStream(fileName,
-                            FileMode.OpenOrCreate,
-                            FileAccess.Write,
-                            FileShare.ReadWrite);
-
-                        file.Flush();
-                        success = true;
-                    }
-                    finally
-                    {
-                        if (file != null)
-                            file.Close();
-                    }
-                }
-                catch (IOException ioe)
-                {
-                    if (exc == null)
-                        exc = ioe;
-                    try
-                    {
-                        // Pause 5 msec
-                        System.Threading.Thread.Sleep(new TimeSpan((Int64)10000 * 5));
-                    }
-                    catch (System.Threading.ThreadInterruptedException ie)
-                    {
-                        Support.ThreadClass.Current().Interrupt();
-                        throw new System.Threading.ThreadInterruptedException(ie.ToString(),
ie);
-                    }
-                }
+                return f.Length;
             }
-
-            if (!success)
-                if (exc != null) throw exc;
         }
 
-        /// <summary>
-        /// Creates an IndexOutput for the file with the given name.
-        /// <em>In 3.0 this method will become abstract.</em> 
-        /// </summary>
         public override IndexOutput CreateOutput(string name)
         {
-            InitOutput(name);
-            return new IsolatedStorageOutputStream(GetIsoStoragePath(name), ref IsoDirectory);
+            return new IsolatedStorageIndexOutput(_is, Path.Combine(_dirName, name));
         }
 
-        /// <summary>
-        /// Returns a stream reading an existing file. 
-        /// </summary>
         public override IndexInput OpenInput(string name)
         {
-            return new IsolatedStorageInputStream(GetIsoStoragePath(name), ref IsoDirectory);
+            return new IsolatedStorageIndexInput(_is, Path.Combine(_dirName, name));
         }
 
-        /// <summary>
-        /// Closes the store to future operations. 
-        /// </summary>
         public override void Close()
         {
-            IsoDirectory.Close();
+            _is.Close();
         }
 
-        /// <summary>
-        /// For .Net Using
-        /// </summary>
         public override void Dispose()
         {
-            IsoDirectory.Close();
-        }
-
-        /// <summary>
-        /// For debug output. 
-        /// </summary>
-        public override string ToString()
-        {
-            return GetType().FullName + "@" + IsoDirectoryPath + " lockFactory=" + GetLockFactory();
+            Close();
         }
 
-        #region Obsolete
 
-        /// <summary>
-        /// Renames an existing file in the directory - overwriting the to file if exists
-        /// </summary>
-        /// <deprecated> 
-        /// </deprecated>
-        [Obsolete("Not Implimented")]
-        public override void RenameFile(string from, string to)
+        private long GetDate(DateTime dt)
         {
-            throw new NotImplementedException("This method (IsolatedStorageDirectory.RenameFile)
is Obsolete");
+            return (long)dt.ToUniversalTime().Subtract(new DateTime(1970, 1, 1, 0, 0, 0)).TotalMilliseconds;
         }
-
-        /// <summary>
-        /// Lists all files (not subdirectories) in the directory.
-        /// </summary>
-        [Obsolete("Lucene.Net-2.9.1. This method overrides obsolete member Lucene.Net.Store.Directory.List()")]
-        public override String[] List()
-        {
-            return IsoDirectory.GetFileNames();
-        }
-
-        #endregion
-
-        #region Private Helpers
-
-        /// <summary>
-        /// Prepends filenames with the correct path
-        /// </summary>
-        /// <param name="file"></param>
-        /// <returns></returns>
-        private string GetIsoStoragePath(string file)
-        {
-            return IsoDirectoryPath + '/' + file;
-        }
-
-        #endregion
     }
 }
\ No newline at end of file

Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/IsolatedStorage/IsolatedStorageIndexInput.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/IsolatedStorage/IsolatedStorageIndexInput.cs?rev=1162569&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/IsolatedStorage/IsolatedStorageIndexInput.cs
(added)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/IsolatedStorage/IsolatedStorageIndexInput.cs
Sun Aug 28 18:32:24 2011
@@ -0,0 +1,91 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.IO;
+using System.IO.IsolatedStorage;
+
+namespace Lucene.Net.Store
+{
+    /// <summary>
+    /// Isolated Storage Input Stream
+    /// </summary>
+    public class IsolatedStorageIndexInput : Lucene.Net.Store.BufferedIndexInput, IDisposable
+    {
+        System.IO.IsolatedStorage.IsolatedStorageFileStream _file;
+        bool _isClone = false;
+
+        public IsolatedStorageIndexInput(System.IO.IsolatedStorage.IsolatedStorageFile dir,
string name)
+        {
+            try
+            {
+                _file = dir.OpenFile(name, FileMode.Open);
+            }
+            catch (InvalidOperationException e)
+            {
+                throw new AlreadyClosedException(e.Message);
+            }
+
+        }
+
+        public override System.Object Clone()
+        {
+            IsolatedStorageIndexInput clone = (IsolatedStorageIndexInput)base.Clone();
+            clone._isClone = true;
+            return clone;
+        }
+
+        public override void ReadInternal(byte[] b, int offset, int len)
+        {
+            lock (_file)
+            {
+                long position = GetFilePointer();
+                if (position != _file.Position)
+                {
+                    _file.Position = position;
+                }
+
+                int read = 0;
+                while (read != len)
+                {
+                    read += _file.Read(b, offset + read, len - read);
+                }
+            }
+        }
+
+        public override void Close()
+        {
+            if (!_isClone)
+                _file.Close();
+        }
+
+        public void Dispose()
+        {
+            Close();
+        }
+
+        public override void SeekInternal(long pos)
+        {
+
+        }
+
+        public override long Length()
+        {
+            return _file.Length;
+        }
+    }
+}
\ No newline at end of file

Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/IsolatedStorage/IsolatedStorageIndexOutput.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/IsolatedStorage/IsolatedStorageIndexOutput.cs?rev=1162569&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/IsolatedStorage/IsolatedStorageIndexOutput.cs
(added)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/IsolatedStorage/IsolatedStorageIndexOutput.cs
Sun Aug 28 18:32:24 2011
@@ -0,0 +1,82 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.IO;
+using System.IO.IsolatedStorage;
+
+namespace Lucene.Net.Store
+{
+    public class IsolatedStorageIndexOutput : Lucene.Net.Store.BufferedIndexOutput, IDisposable
+    {
+        System.IO.IsolatedStorage.IsolatedStorageFileStream _file;
+        bool _isOpen;
+
+        public IsolatedStorageIndexOutput(System.IO.IsolatedStorage.IsolatedStorageFile dir,
string name)
+        {
+            try
+            {
+                _file = dir.CreateFile(name);
+                _isOpen = true;
+            }
+            catch (InvalidOperationException e)
+            {
+                throw new AlreadyClosedException(e.Message);
+            }
+        }
+
+
+        public override void FlushBuffer(byte[] b, int offset, int len)
+        {
+            _file.Write(b, offset, len);
+            _file.Flush();
+        }
+
+
+        public override void Close()
+        {
+            if (_isOpen)
+            {
+                _isOpen = false;
+                base.Close();
+                _file.Close();
+            }
+        }
+
+        public void Dispose()
+        {
+            Close();
+        }
+
+
+        public override void Seek(long pos)
+        {
+            base.Seek(pos);
+            _file.Seek(pos, SeekOrigin.Begin);
+        }
+
+        public override long Length()
+        {
+            return _file.Length;
+        }
+
+        public override void SetLength(long length)
+        {
+            _file.SetLength(length);
+        }
+    }
+}

Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/IsolatedStorage/IsolatedStorageLock.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/IsolatedStorage/IsolatedStorageLock.cs?rev=1162569&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/IsolatedStorage/IsolatedStorageLock.cs
(added)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/IsolatedStorage/IsolatedStorageLock.cs
Sun Aug 28 18:32:24 2011
@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Lucene.Net.Store
+{
+    internal class IsolatedStorageLock : Lucene.Net.Store.Lock
+    {
+
+        System.IO.IsolatedStorage.IsolatedStorageFile _dir;
+        System.IO.IsolatedStorage.IsolatedStorageFileStream _file;
+        string _name;
+
+        public IsolatedStorageLock(System.IO.IsolatedStorage.IsolatedStorageFile dir, string
name)
+        {
+            _dir = dir;
+            _name = name;
+
+        }
+
+        public override bool Obtain()
+        {
+            try
+            {
+                _file = _dir.CreateFile(_name);
+                return true;
+            }
+            catch
+            {
+                return false;
+            }
+        }
+
+        public override void Release()
+        {
+            _file.Close();
+            _dir.DeleteFile(_name);
+
+        }
+
+        public override bool IsLocked()
+        {
+            return _dir.FileExists(_name);
+        }
+    }
+}

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/contrib/IsolatedStorage/Contrib.IsolatedStorage.Test.csproj
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/contrib/IsolatedStorage/Contrib.IsolatedStorage.Test.csproj?rev=1162569&r1=1162568&r2=1162569&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/contrib/IsolatedStorage/Contrib.IsolatedStorage.Test.csproj
(original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/contrib/IsolatedStorage/Contrib.IsolatedStorage.Test.csproj
Sun Aug 28 18:32:24 2011
@@ -17,7 +17,7 @@
     <DebugSymbols>true</DebugSymbols>
     <DebugType>full</DebugType>
     <Optimize>false</Optimize>
-    <OutputPath>bin\Debug\</OutputPath>
+    <OutputPath>..\..\..\bin\contrib\IsolatedStorage\Debug\</OutputPath>
     <DefineConstants>DEBUG;TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>



Mime
View raw message