Ignore:
Timestamp:
06/10/08 10:03:03 (16 years ago)
Author:
ra33
Message:

Lots of changes!!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/gui/FrameIO.java

    r95 r97  
    138138
    139139        public static Frame LoadFrame(String frameName) {
    140                 // If the frame name is a positive integer add the frameset name
    141                 if (isPositiveInteger(frameName)) {
    142                         assert (false);
    143                         frameName = DisplayIO.getCurrentFrame().getFramesetName()
    144                                         + frameName;
    145                 }
     140                if (!isValidFrameName(frameName))
     141                        return null;
    146142
    147143                // first try reading from cache
     
    181177
    182178                for (String path : UserSettings.FrameDirs) {
     179                        File files = new File(path);
     180                        if (!files.exists())
     181                                continue;
    183182                        for (File f : (new File(path)).listFiles()) {
    184183                                if (f.isDirectory()) {
     
    203202         */
    204203        public static String getFrameFullPathName(String path, String frameName) {
    205                 String source = path + Conversion.getFrameset(frameName)
     204                String source = path + Conversion.getFramesetName(frameName)
    206205                                + File.separator;
    207206
     
    219218
    220219                // check for oldfile name format
    221                 fullPath = source + Conversion.getFrameset(frameName) + "."
     220                fullPath = source + Conversion.getFramesetName(frameName) + "."
    222221                                + Conversion.getFrameNumber(frameName);
    223222                tester = new File(fullPath);
     
    229228        }
    230229
    231         public static boolean DoesFrameExist(String frameName) {
     230        public static boolean canAccessFrame(String frameName) {
    232231                for (String path : UserSettings.FrameDirs) {
    233232                        if (getFrameFullPathName(path, frameName) != null)
     
    421420         * @return The result of File.delete()
    422421         */
    423         public static boolean DeleteFrame(Frame toDelete) throws IOException {
     422        public static boolean DeleteFrame(Frame toDelete) throws IOException,
     423                        SecurityException {
    424424                if (toDelete == null)
    425425                        return false;
     
    427427                // Dont delete the zero frame
    428428                if (toDelete.getNumber() == 0) {
    429                         FrameGraphics.ErrorMessage("Zero frame's can not be deleted");
    430                         return false;
     429                        throw new SecurityException("Deleting a zero frame is illegal");
    431430                }
    432431
    433432                SaveFrame(toDelete);
    434433
     434                // Copy deleted frames to the DeletedFrames frameset
    435435                // get the last used frame in the destination frameset
    436436                final String DELETED_FRAMES = "DeletedFrames";
     
    765765                        // re-parsing)
    766766                        if (isProfileFrame(toSave)) {
    767                                 Frame profile = FrameIO.LoadFrame(toSave.getFramesetName()+ "1");
    768                                 assert(profile != null);
     767                                Frame profile = FrameIO.LoadFrame(toSave.getFramesetName()
     768                                                + "1");
     769                                assert (profile != null);
    769770                                FrameUtils.ParseProfile(profile);
    770771                        }
     
    780781        /**
    781782         * Checks if a frame is in the current user profile frameset.
    782          * @param toCheck the frame to check
     783         *
     784         * @param toCheck
     785         *            the frame to check
    783786         * @return true if the frame is in the current user profile frameset
    784787         */
    785788        public static boolean isProfileFrame(Frame toCheck) {
    786                 if(toCheck.getNumber() == 0)
     789                if (toCheck.getNumber() == 0)
    787790                        return false;
    788791                return toCheck.getFramesetName()
    789                 .equalsIgnoreCase(UserSettings.Username);
     792                                .equalsIgnoreCase(UserSettings.Username);
    790793        }
    791794
     
    973976        }
    974977
    975         public static Boolean DoesFramesetExist(String framesetName) {
    976                 String zeroFrame = framesetName + '0';
    977                 return FrameIO.DoesFrameExist(zeroFrame);
     978        /**
     979         * Checks if a given frameset is accessable.
     980         *
     981         * @param framesetName
     982         * @return
     983         */
     984        public static Boolean canAccessFrameset(String framesetName) {
     985                framesetName = framesetName.toLowerCase();
     986                for (String path : UserSettings.FrameDirs) {
     987                        if ((new File(path + framesetName)).exists())
     988                                return true;
     989                }
     990                return false;
    978991        }
    979992
     
    986999                }
    9871000
    988                 if (!recreate && FrameIO.DoesFramesetExist(frameset)) {
     1001                if (!recreate && FrameIO.canAccessFrameset(frameset)) {
    9891002                        throw new ExistingFramesetException(frameset);
    9901003                }
     
    10811094
    10821095        public static boolean DeleteFrameset(String framesetName) {
    1083                 if (!FrameIO.DoesFramesetExist(framesetName))
     1096                if (!FrameIO.canAccessFrameset(framesetName))
    10841097                        return false;
    10851098                // Search all the available directories for the directory
     
    11091122        public static boolean CopyFrameset(String framesetToCopy,
    11101123                        String copiedFrameset) throws Exception {
    1111                 if (!FrameIO.DoesFramesetExist(framesetToCopy))
     1124                if (!FrameIO.canAccessFrameset(framesetToCopy))
    11121125                        return false;
    1113                 if (FrameIO.DoesFramesetExist(copiedFrameset))
     1126                if (FrameIO.canAccessFrameset(copiedFrameset))
    11141127                        return false;
    11151128                // search through all the directories to find the frameset we are
     
    11271140                                // copy each of the frames
    11281141                                for (File f : framesetDirectory.listFiles()) {
     1142                                        // Ignore hidden files
     1143                                        if (f.getName().charAt(0) == '.')
     1144                                                continue;
    11291145                                        String copyPath = copyFramesetDirectory.getAbsolutePath()
    11301146                                                        + File.separator + f.getName();
Note: See TracChangeset for help on using the changeset viewer.