1 /* 2 * Copyright (C) 2009,2010 Matthias Treydte <mt@waldheinz.de> 3 * 4 * This library is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU Lesser General Public License as published 6 * by the Free Software Foundation; either version 2.1 of the License, or 7 * (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, but 10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 12 * License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public License 15 * along with this library; If not, write to the Free Software Foundation, Inc., 16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 */ 18 19 package de.waldheinz.fs; 20 21 import de.waldheinz.fs.fat.FatFileSystem; 22 import java.io.IOException; 23 24 /** 25 * Factory for {@link FileSystem} instances. 26 * 27 * @author Matthias Treydte <waldheinz at gmail.com> 28 */ 29 public class FileSystemFactory { 30 FileSystemFactory()31 private FileSystemFactory() { } 32 33 /** 34 * <p> 35 * Creates a new {@link FileSystem} for the specified {@code device}. When 36 * using this method, care must be taken that there is only one 37 * {@code FileSystems} accessing the specified {@link BlockDevice}. 38 * Otherwise severe file system corruption may occur. 39 * </p> 40 * 41 * @param device the device to create the file system for 42 * @param readOnly if the file system should be openend read-only 43 * @return a new {@code FileSystem} instance for the specified device 44 * @throws UnknownFileSystemException if the file system type could 45 * not be determined 46 * @throws IOException on read error 47 */ create(BlockDevice device, boolean readOnly)48 public static FileSystem create(BlockDevice device, boolean readOnly) 49 throws UnknownFileSystemException, IOException { 50 51 return FatFileSystem.read(device, readOnly); 52 } 53 } 54