Lines 1709-1712
Link Here
|
1709 |
return wrapFileNoCanonicalize(delegate.createFileObject(path)); |
1709 |
return wrapFileNoCanonicalize(delegate.createFileObject(path)); |
1710 |
} |
1710 |
} |
1711 |
} |
1711 |
} |
|
|
1712 |
|
1713 |
/** |
1714 |
* Get a data file or folder from the System (configuration) Filesystem |
1715 |
* with the specified file path. |
1716 |
* |
1717 |
* @param path The path from the root of the System Filesystem to the file, |
1718 |
* including its name and extension. |
1719 |
* @return A FileObject for that file in the system filesystem |
1720 |
*/ |
1721 |
public static FileObject getConfigurationFile (String path) { |
1722 |
if (path == null) { |
1723 |
throw new NullPointerException ("Null path to file"); //NOI18N |
1724 |
} |
1725 |
FileSystem sfs = Repository.getDefault().getDefaultFileSystem(); |
1726 |
FileObject root = sfs.getRoot(); |
1727 |
FileObject result = root.getFileObject(path); |
1728 |
assert result == null || result.isData() : "Not a data file: " + path; //NOI18N |
1729 |
return result; |
1730 |
} |
1731 |
|
1732 |
/** |
1733 |
* Get a data file or folder from the System (configuration) Filesystem |
1734 |
* with the specified file path, creating a new empty file if the specified |
1735 |
* file does not exist. |
1736 |
* |
1737 |
* @param path The path from the root of the System Filesystem to the file, |
1738 |
* including its name and extension. |
1739 |
* @return A FileObject for that file in the system filesystem |
1740 |
* @throws IOException if the file did not previously exist and could not be |
1741 |
* created for some reason |
1742 |
*/ |
1743 |
public static FileObject getOrCreateConfigurationFile (String path) throws |
1744 |
IOException { |
1745 |
FileObject result = getConfigurationFile (path); |
1746 |
if (result == null) { |
1747 |
FileSystem sfs = Repository.getDefault().getDefaultFileSystem(); |
1748 |
FileObject root = sfs.getRoot(); |
1749 |
result = createData(root, path); |
1750 |
} |
1751 |
return result; |
1752 |
} |
1753 |
|
1754 |
/** |
1755 |
* Get a folder in the System (configuration) Filesystem with the |
1756 |
* specified file path. |
1757 |
* |
1758 |
* @param path The path from the root of the System Filesystem to the folder. |
1759 |
* If the path is the empty string, returns the root of the |
1760 |
* system filesystem (do not use "/" for the root). |
1761 |
* @return A FileObject representing a new file created with the specified |
1762 |
* path, or one representing the existing file if the file already |
1763 |
* was present, or null if an I/O error occurred when trying to |
1764 |
* create a non-existent folder |
1765 |
*/ |
1766 |
public static FileObject getConfigurationFolder (String path) { |
1767 |
if (path == null) { |
1768 |
throw new NullPointerException ("Null path"); //NOI18N |
1769 |
} |
1770 |
FileSystem sfs = Repository.getDefault().getDefaultFileSystem(); |
1771 |
FileObject root = sfs.getRoot(); |
1772 |
FileObject result = path.length() == 0 ? //NOI18N |
1773 |
root : root.getFileObject(path); |
1774 |
assert result == null || result.isFolder() : "Not a folder: " + path; //NOI18N |
1775 |
return result; |
1776 |
} |
1777 |
|
1778 |
/** |
1779 |
* Get a folder in the System (configuration) Filesystem with the |
1780 |
* specified file path, creating it if necessary. |
1781 |
* |
1782 |
* @param path The path from the root of the System Filesystem to the folder. |
1783 |
* If the path is the empty string, returns the root of the |
1784 |
* system filesystem (do not use "/" for the root). |
1785 |
* @return A FileObject representing a new file created with the specified |
1786 |
* path, or one representing the existing file if the file already |
1787 |
* was present, or null if an I/O error occurred when trying to |
1788 |
* create a non-existent folder |
1789 |
* @throws IOException if an error occurs creating the folder |
1790 |
*/ |
1791 |
public static FileObject getOrCreateConfigurationFolder (String path) throws IOException { |
1792 |
FileObject result = getConfigurationFolder(path); |
1793 |
if (result == null) { |
1794 |
FileSystem sfs = Repository.getDefault().getDefaultFileSystem(); |
1795 |
FileObject root = sfs.getRoot(); |
1796 |
result = createFolder (root, path); |
1797 |
} |
1798 |
return result; |
1799 |
} |
1712 |
} |
1800 |
} |