--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<fileset-config file-format-version="1.2.0" simple-config="true">\r
+ <local-check-config name="Uguu Checks" location="uguu-checkstyle-20070925.xml" type="project" description="">\r
+ <additional-data name="protect-config-file" value="false"/>\r
+ </local-check-config>\r
+ <fileset name="all" enabled="true" check-config-name="Uguu Checks" local="true">\r
+ <file-match-pattern match-pattern="." include-pattern="true"/>\r
+ </fileset>\r
+</fileset-config>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+ <classpathentry kind="src" path="src/main/java"/>\r
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>\r
+ <classpathentry kind="output" path="bin"/>\r
+</classpath>\r
--- /dev/null
+#FindBugs User Preferences\r
+#Tue Sep 25 00:36:36 JST 2007\r
+detectorBadAppletConstructor=BadAppletConstructor|false\r
+detectorBadResultSetAccess=BadResultSetAccess|true\r
+detectorBadSyntaxForRegularExpression=BadSyntaxForRegularExpression|true\r
+detectorBadUseOfReturnValue=BadUseOfReturnValue|true\r
+detectorBadlyOverriddenAdapter=BadlyOverriddenAdapter|true\r
+detectorCheckImmutableAnnotation=CheckImmutableAnnotation|true\r
+detectorCloneIdiom=CloneIdiom|true\r
+detectorComparatorIdiom=ComparatorIdiom|true\r
+detectorConfusedInheritance=ConfusedInheritance|true\r
+detectorConfusionBetweenInheritedAndOuterMethod=ConfusionBetweenInheritedAndOuterMethod|true\r
+detectorDoInsideDoPrivileged=DoInsideDoPrivileged|true\r
+detectorDontCatchIllegalMonitorStateException=DontCatchIllegalMonitorStateException|true\r
+detectorDontUseEnum=DontUseEnum|true\r
+detectorDroppedException=DroppedException|true\r
+detectorDumbMethodInvocations=DumbMethodInvocations|true\r
+detectorDumbMethods=DumbMethods|true\r
+detectorDuplicateBranches=DuplicateBranches|true\r
+detectorEmptyZipFileEntry=EmptyZipFileEntry|true\r
+detectorFinalizerNullsFields=FinalizerNullsFields|true\r
+detectorFindBadCast2=FindBadCast2|true\r
+detectorFindBadForLoop=FindBadForLoop|true\r
+detectorFindCircularDependencies=FindCircularDependencies|false\r
+detectorFindDeadLocalStores=FindDeadLocalStores|true\r
+detectorFindDoubleCheck=FindDoubleCheck|true\r
+detectorFindEmptySynchronizedBlock=FindEmptySynchronizedBlock|true\r
+detectorFindFieldSelfAssignment=FindFieldSelfAssignment|true\r
+detectorFindFinalizeInvocations=FindFinalizeInvocations|true\r
+detectorFindFloatEquality=FindFloatEquality|true\r
+detectorFindHEmismatch=FindHEmismatch|true\r
+detectorFindInconsistentSync2=FindInconsistentSync2|true\r
+detectorFindJSR166LockMonitorenter=FindJSR166LockMonitorenter|true\r
+detectorFindLocalSelfAssignment2=FindLocalSelfAssignment2|true\r
+detectorFindMaskedFields=FindMaskedFields|true\r
+detectorFindMismatchedWaitOrNotify=FindMismatchedWaitOrNotify|true\r
+detectorFindNakedNotify=FindNakedNotify|true\r
+detectorFindNonSerializableStoreIntoSession=FindNonSerializableStoreIntoSession|true\r
+detectorFindNonSerializableValuePassedToWriteObject=FindNonSerializableValuePassedToWriteObject|true\r
+detectorFindNonShortCircuit=FindNonShortCircuit|true\r
+detectorFindNullDeref=FindNullDeref|true\r
+detectorFindOpenStream=FindOpenStream|true\r
+detectorFindPuzzlers=FindPuzzlers|true\r
+detectorFindRefComparison=FindRefComparison|true\r
+detectorFindReturnRef=FindReturnRef|true\r
+detectorFindRunInvocations=FindRunInvocations|true\r
+detectorFindSelfComparison=FindSelfComparison|true\r
+detectorFindSelfComparison2=FindSelfComparison2|true\r
+detectorFindSleepWithLockHeld=FindSleepWithLockHeld|true\r
+detectorFindSpinLoop=FindSpinLoop|true\r
+detectorFindSqlInjection=FindSqlInjection|true\r
+detectorFindTwoLockWait=FindTwoLockWait|true\r
+detectorFindUncalledPrivateMethods=FindUncalledPrivateMethods|true\r
+detectorFindUnconditionalWait=FindUnconditionalWait|true\r
+detectorFindUninitializedGet=FindUninitializedGet|true\r
+detectorFindUnrelatedTypesInGenericContainer=FindUnrelatedTypesInGenericContainer|true\r
+detectorFindUnreleasedLock=FindUnreleasedLock|true\r
+detectorFindUnsyncGet=FindUnsyncGet|true\r
+detectorFindUselessControlFlow=FindUselessControlFlow|true\r
+detectorHugeSharedStringConstants=HugeSharedStringConstants|true\r
+detectorIDivResultCastToDouble=IDivResultCastToDouble|true\r
+detectorIncompatMask=IncompatMask|true\r
+detectorInefficientMemberAccess=InefficientMemberAccess|false\r
+detectorInefficientToArray=InefficientToArray|true\r
+detectorInfiniteLoop=InfiniteLoop|true\r
+detectorInfiniteRecursiveLoop=InfiniteRecursiveLoop|true\r
+detectorInfiniteRecursiveLoop2=InfiniteRecursiveLoop2|false\r
+detectorInheritanceUnsafeGetResource=InheritanceUnsafeGetResource|true\r
+detectorInitializationChain=InitializationChain|true\r
+detectorInstantiateStaticClass=InstantiateStaticClass|true\r
+detectorInvalidJUnitTest=InvalidJUnitTest|true\r
+detectorIteratorIdioms=IteratorIdioms|true\r
+detectorLazyInit=LazyInit|true\r
+detectorLoadOfKnownNullValue=LoadOfKnownNullValue|true\r
+detectorMethodReturnCheck=MethodReturnCheck|true\r
+detectorMultithreadedInstanceAccess=MultithreadedInstanceAccess|true\r
+detectorMutableLock=MutableLock|true\r
+detectorMutableStaticFields=MutableStaticFields|true\r
+detectorNaming=Naming|true\r
+detectorNumberConstructor=NumberConstructor|true\r
+detectorPreferZeroLengthArrays=PreferZeroLengthArrays|true\r
+detectorPublicSemaphores=PublicSemaphores|false\r
+detectorQuestionableBooleanAssignment=QuestionableBooleanAssignment|true\r
+detectorReadReturnShouldBeChecked=ReadReturnShouldBeChecked|true\r
+detectorRedundantInterfaces=RedundantInterfaces|true\r
+detectorRuntimeExceptionCapture=RuntimeExceptionCapture|true\r
+detectorSerializableIdiom=SerializableIdiom|true\r
+detectorStartInConstructor=StartInConstructor|true\r
+detectorStaticCalendarDetector=StaticCalendarDetector|true\r
+detectorStringConcatenation=StringConcatenation|true\r
+detectorSuperfluousInstanceOf=SuperfluousInstanceOf|true\r
+detectorSuspiciousThreadInterrupted=SuspiciousThreadInterrupted|true\r
+detectorSwitchFallthrough=SwitchFallthrough|true\r
+detectorSynchronizeAndNullCheckField=SynchronizeAndNullCheckField|true\r
+detectorTestASM=TestASM|false\r
+detectorURLProblems=URLProblems|true\r
+detectorUncallableMethodOfAnonymousClass=UncallableMethodOfAnonymousClass|true\r
+detectorUnnecessaryMath=UnnecessaryMath|true\r
+detectorUnreadFields=UnreadFields|true\r
+detectorUseObjectEquals=UseObjectEquals|false\r
+detectorUselessSubclassMethod=UselessSubclassMethod|false\r
+detectorVarArgsProblems=VarArgsProblems|true\r
+detectorVolatileUsage=VolatileUsage|true\r
+detectorWaitInLoop=WaitInLoop|true\r
+detectorWrongMapIterator=WrongMapIterator|true\r
+detectorXMLFactoryBypass=XMLFactoryBypass|true\r
+detector_threshold=2\r
+filter_settings=Medium|MALICIOUS_CODE,STYLE,BAD_PRACTICE,CORRECTNESS,I18N,PERFORMANCE,MT_CORRECTNESS|false\r
+filter_settings_neg=|\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+ <name>filelock</name>\r
+ <comment></comment>\r
+ <projects>\r
+ </projects>\r
+ <buildSpec>\r
+ <buildCommand>\r
+ <name>org.eclipse.jdt.core.javabuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ <buildCommand>\r
+ <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ <buildCommand>\r
+ <name>edu.umd.cs.findbugs.plugin.eclipse.findbugsBuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ </buildSpec>\r
+ <natures>\r
+ <nature>org.eclipse.jdt.core.javanature</nature>\r
+ <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>\r
+ <nature>edu.umd.cs.findbugs.plugin.eclipse.findbugsNature</nature>\r
+ </natures>\r
+</projectDescription>\r
--- /dev/null
+/*
+ * Copyright (C) 2007 uguu at users.sourceforge.jp, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="Shift_JIS"?>\r
+<project>\r
+ <modelVersion>4.0.0</modelVersion>\r
+ <groupId>jp.sourceforge.filelock</groupId>\r
+ <artifactId>filelock</artifactId>\r
+ <name>filelock</name>\r
+ <version>1.0.0</version>\r
+ <description>\81ufilelock\81v\82Í\81A\83t\83@\83C\83\8b\82ð\83\8d\83b\83N\82·\82é\82¾\82¯\82Ì\92P\8f\83\82È\83c\81[\83\8b\82Å\82·\81B</description>\r
+ <url>http://filelock.sourceforge.jp/</url>\r
+ <inceptionYear>2007</inceptionYear>\r
+ <developers>\r
+ <developer>\r
+ <id>uguu</id>\r
+ <name>uguu</name>\r
+ <email>uguu at users.sourceforge.jp</email>\r
+ <organization />\r
+ <roles>\r
+ <role>Developer</role>\r
+ </roles>\r
+ </developer>\r
+ </developers>\r
+ <licenses>\r
+ <license>\r
+ <name>BSD License</name>\r
+ <url>LICENSE.txt</url>\r
+ </license>\r
+ </licenses>\r
+ <!--\r
+ <scm>\r
+ <connection>scm:svn:http://svn.sourceforge.jp/svnroot/filelock/filelock/</connection>\r
+ <url>http://svn.sourceforge.jp/svnroot/filelock/filelock/</url>\r
+ </scm>\r
+ -->\r
+ <organization>\r
+ <name>uguu</name>\r
+ </organization>\r
+ <build>\r
+ <plugins>\r
+ <plugin>\r
+ <groupId>org.apache.maven.plugins</groupId>\r
+ <artifactId>maven-compiler-plugin</artifactId>\r
+ <configuration>\r
+ <source>1.5</source>\r
+ <target>1.5</target>\r
+ </configuration>\r
+ </plugin>\r
+ <plugin>\r
+ <groupId>org.apache.maven.plugins</groupId>\r
+ <artifactId>maven-site-plugin</artifactId>\r
+ <configuration>\r
+ <locales>ja</locales>\r
+ <inputEncoding>Shift_JIS</inputEncoding>\r
+ <outputEncoding>Shift_JIS</outputEncoding>\r
+ </configuration>\r
+ </plugin>\r
+ <plugin>\r
+ <groupId>org.apache.maven.plugins</groupId>\r
+ <artifactId>maven-assembly-plugin</artifactId>\r
+ <configuration>\r
+ <descriptors>\r
+ <descriptor>src/main/assembly/dist.xml</descriptor>\r
+ </descriptors>\r
+ </configuration>\r
+ </plugin>\r
+ <plugin>\r
+ <groupId>org.apache.maven.plugins</groupId>\r
+ <artifactId>maven-jar-plugin</artifactId>\r
+ <configuration>\r
+ <archive>\r
+ <manifest>\r
+ <mainClass>jp.sourceforge.filelock.ConsoleMain</mainClass>\r
+ </manifest>\r
+ </archive>\r
+ </configuration>\r
+ </plugin>\r
+ </plugins>\r
+ </build>\r
+ <reporting>\r
+ <plugins>\r
+ <plugin>\r
+ <groupId>org.apache.maven.plugins</groupId>\r
+ <artifactId>maven-surefire-report-plugin</artifactId>\r
+ </plugin>\r
+ <plugin>\r
+ <groupId>org.apache.maven.plugins</groupId>\r
+ <artifactId>maven-javadoc-plugin</artifactId>\r
+ <configuration>\r
+ <source>1.5</source>\r
+ <encoding>UTF-8</encoding>\r
+ <charset>Shift_JIS</charset>\r
+ <docencoding>Shift_JIS</docencoding>\r
+ <links>\r
+ <link>http://java.sun.com/j2se/1.5.0/ja/docs/ja/api/</link>\r
+ </links>\r
+ </configuration>\r
+ </plugin>\r
+ <!--\r
+ <plugin>\r
+ <groupId>org.apache.maven.plugins</groupId>\r
+ <artifactId>maven-changelog-plugin</artifactId>\r
+ </plugin>\r
+ -->\r
+ <plugin>\r
+ <groupId>org.apache.maven.plugins</groupId>\r
+ <artifactId>maven-changes-plugin</artifactId>\r
+ <configuration>\r
+ <xmlPath>${basedir}/src/site/changes.xml</xmlPath>\r
+ </configuration>\r
+ <reportSets>\r
+ <reportSet>\r
+ <reports>\r
+ <report>changes-report</report>\r
+ </reports>\r
+ </reportSet>\r
+ </reportSets>\r
+ </plugin>\r
+ <plugin>\r
+ <groupId>org.apache.maven.plugins</groupId>\r
+ <artifactId>maven-checkstyle-plugin</artifactId>\r
+ <configuration>\r
+ <configLocation>uguu-checkstyle-20070925.xml</configLocation>\r
+ <propertyExpansion>basedir=./</propertyExpansion>\r
+ </configuration>\r
+ </plugin>\r
+ </plugins>\r
+ </reporting>\r
+</project>\r
--- /dev/null
+<?xml version="1.0" encoding="Shift_JIS"?>\r
+<assembly>\r
+ <formats>\r
+ <format>zip</format>\r
+ <format>tar.gz</format>\r
+ </formats>\r
+ <fileSets>\r
+ <fileSet>\r
+ <directory>src</directory>\r
+ <outputDirectory>src</outputDirectory>\r
+ </fileSet>\r
+ <fileSet>\r
+ <directory>target/site</directory>\r
+ <outputDirectory>docs</outputDirectory>\r
+ </fileSet>\r
+ <fileSet>\r
+ <directory>target</directory>\r
+ <outputDirectory>bin</outputDirectory>\r
+ <includes>\r
+ <include>*.jar</include>\r
+ </includes>\r
+ </fileSet>\r
+ <fileSet>\r
+ <includes>\r
+ <include>LICENSE.txt</include>\r
+ <include>pom.xml</include>\r
+ <include>uguu-checkstyle-20070925.xml</include>\r
+ </includes>\r
+ </fileSet>\r
+ </fileSets>\r
+ <dependencySets>\r
+ <dependencySet>\r
+ <unpack>false</unpack>\r
+ <outputDirectory>lib</outputDirectory>\r
+ </dependencySet>\r
+ </dependencySets>\r
+</assembly>\r
--- /dev/null
+/*\r
+ * Copyright (C) 2007 uguu at users.sourceforge.jp, All Rights Reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions\r
+ * are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright\r
+ * notice, this list of conditions and the following disclaimer.\r
+ *\r
+ * 2. Redistributions in binary form must reproduce the above copyright\r
+ * notice, this list of conditions and the following disclaimer in the\r
+ * documentation and/or other materials provided with the distribution.\r
+ *\r
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its\r
+ * contributors may be used to endorse or promote products derived\r
+ * from this software without prior written permission. For written\r
+ * permission, please contact clarkware@clarkware.com.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,\r
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL\r
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+package jp.sourceforge.filelock;\r
+\r
+import java.io.IOException;\r
+import java.util.Map;\r
+import java.util.TreeMap;\r
+\r
+/**\r
+ * <p>\r
+ * アプリケーションのエントリーポイントです。\r
+ * </p>\r
+ * \r
+ * @author $Author$\r
+ * @version $Rev$ $Date$\r
+ */\r
+public final class ConsoleMain {\r
+\r
+ private ConsoleMain() {\r
+ throw new UnsupportedOperationException();\r
+ }\r
+\r
+ /**\r
+ * <p>\r
+ * アプリケーションのエントリーポイントです。\r
+ * </p>\r
+ * \r
+ * @param args\r
+ * アプリケーション引数。\r
+ * @throws IOException\r
+ * 失敗した場合。\r
+ */\r
+ public static void main(String[] args) throws IOException {\r
+ FileLockUtil flu = new FileLockUtil(args);\r
+\r
+ Map<String, Boolean> lockStateMap = new TreeMap<String, Boolean>();\r
+ for (String path : flu.lockFiles()) {\r
+ lockStateMap.put(path, true);\r
+ }\r
+ for (String path : flu.lockFailFiles()) {\r
+ lockStateMap.put(path, false);\r
+ }\r
+\r
+ for (Map.Entry<String, Boolean> entry : lockStateMap.entrySet()) {\r
+ if (entry.getValue()) {\r
+ System.out.println("LOCK " + entry.getKey());\r
+ } else {\r
+ System.out.println("FAIL " + entry.getKey());\r
+ }\r
+ }\r
+\r
+ System.in.read();\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (C) 2007 uguu at users.sourceforge.jp, All Rights Reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions\r
+ * are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright\r
+ * notice, this list of conditions and the following disclaimer.\r
+ *\r
+ * 2. Redistributions in binary form must reproduce the above copyright\r
+ * notice, this list of conditions and the following disclaimer in the\r
+ * documentation and/or other materials provided with the distribution.\r
+ *\r
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its\r
+ * contributors may be used to endorse or promote products derived\r
+ * from this software without prior written permission. For written\r
+ * permission, please contact clarkware@clarkware.com.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,\r
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL\r
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+package jp.sourceforge.filelock;\r
+\r
+import java.io.File;\r
+import java.io.IOException;\r
+import java.io.RandomAccessFile;\r
+import java.nio.channels.FileChannel;\r
+import java.nio.channels.FileLock;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.TreeMap;\r
+\r
+/**\r
+ * <p>\r
+ * ファイルをロックします。\r
+ * </p>\r
+ * \r
+ * @author $Author$\r
+ * @version $Rev$ $Date$\r
+ */\r
+public final class FileLockUtil {\r
+\r
+ /**\r
+ * <p>\r
+ * ロックしたファイルのパスと{@link FileLock}インスタンスのマップ。\r
+ * </p>\r
+ */\r
+ private Map<String, FileLock> lockMap = new TreeMap<String, FileLock>();\r
+\r
+ /**\r
+ * <p>\r
+ * ファイルとチャネルのマップ。\r
+ * </p>\r
+ */\r
+ private Map<String, FileChannel> channelMap = new TreeMap<String, FileChannel>();\r
+\r
+ /**\r
+ * <p>\r
+ * 指定したファイルをロックし、{@link FileLockUtil}インスタンスを初期化します。ディレクトリを指定した場合、子ファイルを再帰的に検索し、ロックします。ロックに失敗しても例外はスローしません。\r
+ * </p>\r
+ * \r
+ * @param paths\r
+ * ロックするファイルの配列。\r
+ * @throws IOException\r
+ * スローされない。\r
+ */\r
+ public FileLockUtil(String[] paths) throws IOException {\r
+ if (paths == null) {\r
+ throw new NullPointerException("paths");\r
+ }\r
+\r
+ for (String path : paths) {\r
+ File file = new File(path).getCanonicalFile();\r
+ this.lock(file);\r
+ }\r
+ }\r
+\r
+ private void lock(File file) throws IOException {\r
+ if (file.isFile()) {\r
+ FileChannel fch = new RandomAccessFile(file, "rw").getChannel();\r
+ this.channelMap.put(file.getAbsolutePath(), fch);\r
+\r
+ FileLock l = fch.tryLock();\r
+ this.lockMap.put(file.getAbsolutePath(), l);\r
+ } else if (file.isDirectory()) {\r
+ for (File child : file.listFiles()) {\r
+ this.lock(child);\r
+ }\r
+ }\r
+ }\r
+\r
+ /**\r
+ * <p>\r
+ * ロックに成功したファイルのパスの配列を返します。\r
+ * </p>\r
+ * \r
+ * @return ロックに成功したファイルのパスの配列。\r
+ */\r
+ public String[] lockFiles() {\r
+ List<String> files = new ArrayList<String>();\r
+ for (String path : this.lockMap.keySet()) {\r
+ if (this.lockMap.get(path) != null) {\r
+ files.add(path);\r
+ }\r
+ }\r
+ return files.toArray(new String[0]);\r
+ }\r
+\r
+ /**\r
+ * <p>\r
+ * ロックに失敗したファイルのパスの配列を返します。\r
+ * </p>\r
+ * \r
+ * @return ロックに失敗したファイルのパスの配列。\r
+ */\r
+ public String[] lockFailFiles() {\r
+ List<String> files = new ArrayList<String>();\r
+ for (String path : this.lockMap.keySet()) {\r
+ if (this.lockMap.get(path) == null) {\r
+ files.add(path);\r
+ }\r
+ }\r
+ return files.toArray(new String[0]);\r
+ }\r
+\r
+ /**\r
+ * <p>\r
+ * 保持している全てのロックを解除します。\r
+ * </p>\r
+ */\r
+ public void release() {\r
+ for (FileChannel fch : this.channelMap.values()) {\r
+ try {\r
+ fch.close();\r
+ } catch (IOException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+package jp.sourceforge.filelock;\r
+\r
+\r
+public class SwingMain {\r
+\r
+}\r
--- /dev/null
+<body>\r
+<p>「filelock」は、指定したファイルをロックするツールです。。</p>\r
+</body>\r
--- /dev/null
+<?xml version="1.0" encoding="Shift_JIS"?>\r
+<document>\r
+ <properties>\r
+ <title>filelock - \95Ï\8dX\97\9a\97ð</title>\r
+ <author email="uguu at users.sourceforge.jp">uguu</author>\r
+ </properties>\r
+ <body>\r
+ <release version="1.0.0" date="2007-09-25" description="\8dÅ\8f\89\82Ì\83\8a\83\8a\81[\83X">\r
+ <action dev="uguu" type="update">\r
+ \8dÅ\8f\89\82Ì\83\8a\83\8a\81[\83X\82Å\82·\81B\r
+ </action>\r
+ </release>\r
+ </body>\r
+</document>\r
--- /dev/null
+<?xml version="1.0" encoding="Shift_JIS"?>\r
+<project name="deployer">\r
+ <bannerLeft>\r
+ <name>filelock</name>\r
+ <href>http://filelock.sourceforge.jp/</href>\r
+ </bannerLeft>\r
+ <bannerRight>\r
+ <name>SourceForge.jp Project Info</name>\r
+ <src>http://sourceforge.jp/sflogo.php?group_id=2875</src>\r
+ <href>https://sourceforge.jp/projects/filelock/</href>\r
+ </bannerRight>\r
+ <body>\r
+ <links>\r
+ <item name="SourceForge.jp" href="http://sourceforge.jp/" />\r
+ </links>\r
+ <menu name="filelock">\r
+ <!--\r
+ <item name="\8aT\97v" href="index.html" />\r
+ <item name="\83_\83E\83\93\83\8d\81[\83h" href="https://sourceforge.jp/projects/filelock/files/" />\r
+ <item name="\8dX\90V\97\9a\97ð" href="changes-report.html" />\r
+ -->\r
+ </menu>\r
+ <menu ref="reports" />\r
+ </body>\r
+</project>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+ This configuration file was written by the eclipse-cs plugin configuration editor\r
+-->\r
+<!--\r
+ Checkstyle-Configuration: Uguu Checks\r
+ Description: none\r
+-->\r
+<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.2//EN" "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">\r
+<module name="Checker">\r
+ <property name="severity" value="warning"/>\r
+ <module name="TreeWalker">\r
+ <property name="tabWidth" value="4"/>\r
+ <module name="FileContentsHolder"/>\r
+ <module name="ModifierOrder"/>\r
+ <module name="RedundantModifier"/>\r
+ <module name="AvoidNestedBlocks"/>\r
+ <module name="EmptyBlock"/>\r
+ <module name="LeftCurly"/>\r
+ <module name="NeedBraces"/>\r
+ <module name="RightCurly"/>\r
+ <module name="AvoidInlineConditionals"/>\r
+ <module name="DoubleCheckedLocking"/>\r
+ <module name="EmptyStatement"/>\r
+ <module name="EqualsHashCode"/>\r
+ <module name="IllegalInstantiation"/>\r
+ <module name="InnerAssignment"/>\r
+ <module name="MissingSwitchDefault"/>\r
+ <module name="RedundantThrows"/>\r
+ <module name="SimplifyBooleanExpression"/>\r
+ <module name="SimplifyBooleanReturn"/>\r
+ <module name="DesignForExtension"/>\r
+ <module name="HideUtilityClassConstructor"/>\r
+ <module name="InterfaceIsType"/>\r
+ <module name="VisibilityModifier"/>\r
+ <module name="ArrayTypeStyle"/>\r
+ <module name="GenericIllegalRegexp">\r
+ <property name="format" value="\s+$"/>\r
+ <property name="ignoreComments" value="true"/>\r
+ <property name="message" value="Line has trailing spaces."/>\r
+ </module>\r
+ <module name="TodoComment"/>\r
+ <module name="UpperEll"/>\r
+ <module name="DefaultComesLast"/>\r
+ <module name="FallThrough"/>\r
+ <module name="IllegalCatch"/>\r
+ <module name="IllegalThrows"/>\r
+ <module name="ModifiedControlVariable"/>\r
+ <module name="RequireThis"/>\r
+ <module name="StringLiteralEquality"/>\r
+ <module name="FinalClass"/>\r
+ <module name="Indentation"/>\r
+ <module name="TrailingComment"/>\r
+ <module name="JavadocStyle">\r
+ <property name="checkFirstSentence" value="false"/>\r
+ </module>\r
+ <module name="JavadocType">\r
+ <property name="authorFormat" value="^\$Author.*\$$"/>\r
+ <property name="versionFormat" value="^\$Rev.*\$ \$Date.*\$$"/>\r
+ </module>\r
+ <module name="JavadocVariable"/>\r
+ <module name="AbstractClassName"/>\r
+ <module name="ConstantName"/>\r
+ <module name="LocalFinalVariableName"/>\r
+ <module name="LocalVariableName"/>\r
+ <module name="MemberName">\r
+ <property name="format" value="^[a-z_][a-zA-Z0-9]*$"/>\r
+ </module>\r
+ <module name="MethodName"/>\r
+ <module name="PackageName"/>\r
+ <module name="ParameterName"/>\r
+ <module name="StaticVariableName"/>\r
+ <module name="TypeName"/>\r
+ <module name="Header">\r
+ <property name="headerFile" value="${basedir}/LICENSE.txt"/>\r
+ </module>\r
+ <module name="AvoidStarImport"/>\r
+ <module name="IllegalImport"/>\r
+ <module name="ImportOrder"/>\r
+ <module name="RedundantImport"/>\r
+ <module name="UnusedImports"/>\r
+ <module name="EmptyForInitializerPad"/>\r
+ <module name="EmptyForIteratorPad"/>\r
+ <module name="NoWhitespaceAfter"/>\r
+ <module name="NoWhitespaceBefore"/>\r
+ <module name="OperatorWrap"/>\r
+ <module name="MethodParamPad"/>\r
+ <module name="ParenPad"/>\r
+ <module name="TabCharacter"/>\r
+ <module name="TypecastParenPad">\r
+ <property name="tokens" value="RPAREN,TYPECAST"/>\r
+ </module>\r
+ <module name="WhitespaceAfter"/>\r
+ <module name="WhitespaceAround">\r
+ <property name="tokens" value="ASSIGN,BAND,BAND_ASSIGN,BOR,BOR_ASSIGN,BSR,BSR_ASSIGN,BXOR,BXOR_ASSIGN,COLON,DIV,DIV_ASSIGN,EQUAL,GE,GT,LAND,LCURLY,LE,LITERAL_ASSERT,LITERAL_CATCH,LITERAL_DO,LITERAL_ELSE,LITERAL_FINALLY,LITERAL_FOR,LITERAL_IF,LITERAL_RETURN,LITERAL_SYNCHRONIZED,LITERAL_TRY,LITERAL_WHILE,LOR,LT,MINUS,MINUS_ASSIGN,MOD,MOD_ASSIGN,NOT_EQUAL,PLUS,PLUS_ASSIGN,QUESTION,RCURLY,SL,SLIST,SL_ASSIGN,SR,SR_ASSIGN,STAR,STAR_ASSIGN,LITERAL_ASSERT,TYPE_EXTENSION_AND"/>\r
+ </module>\r
+ <module name="CovariantEquals"/>\r
+ <module name="DeclarationOrder"/>\r
+ <module name="ExplicitInitialization"/>\r
+ <module name="HiddenField"/>\r
+ <module name="IllegalType">\r
+ <property name="tokens" value="METHOD_DEF,PARAMETER_DEF,VARIABLE_DEF"/>\r
+ </module>\r
+ <module name="JUnitTestCase"/>\r
+ <module name="MagicNumber"/>\r
+ <module name="MissingCtor"/>\r
+ <module name="MultipleVariableDeclarations"/>\r
+ <module name="PackageDeclaration"/>\r
+ <module name="MutableException"/>\r
+ <module name="JavadocMethod">\r
+ <property name="scope" value="package"/>\r
+ <property name="logLoadErrors" value="true"/>\r
+ <property name="suppressLoadErrors" value="true"/>\r
+ </module>\r
+ </module>\r
+ <module name="NewlineAtEndOfFile">\r
+ <property name="lineSeparator" value="lf"/>\r
+ </module>\r
+ <module name="Translation"/>\r
+ <module name="PackageHtml"/>\r
+ <module name="SuppressionCommentFilter"/>\r
+</module>\r