2 * Copyright (C) 2008 Shawn Pearce <spearce@spearce.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License, version 2, as published by the Free Software Foundation.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
17 package org
.spearce
.jgit
.util
;
21 /** Abstraction to support various file system operations not in Java. */
22 public abstract class FS
{
23 /** The implementation selected for this operating system and JRE. */
24 public static final FS INSTANCE
;
27 if (FS_Win32
.detect())
28 INSTANCE
= new FS_Win32();
29 else if (FS_POSIX_Java6
.detect())
30 INSTANCE
= new FS_POSIX_Java6();
32 INSTANCE
= new FS_POSIX_Java5();
36 * Does this operating system and JRE support the execute flag on files?
38 * @return true if this implementation can provide reasonably accurate
39 * executable bit information; false otherwise.
41 public abstract boolean supportsExecute();
44 * Determine if the file is executable (or not).
46 * Not all platforms and JREs support executable flags on files. If the
47 * feature is unsupported this method will always return false.
50 * abstract path to test.
51 * @return true if the file is believed to be executable by the user.
53 public abstract boolean canExecute(File f
);
56 * Set a file to be executable by the user.
58 * Not all platforms and JREs support executable flags on files. If the
59 * feature is unsupported this method will always return false and no
60 * changes will be made to the file specified.
63 * path to modify the executable status of.
65 * true to enable execution; false to disable it.
66 * @return true if the change succeeded; false otherwise.
68 public abstract boolean setExecute(File f
, boolean canExec
);