Coverage Report - org.jtheque.core.managers.core.io.Folders
 
Classes in this File Line Coverage Branch Coverage Complexity
Folders
0 %
0/26
0 %
0/12
1.857
 
 1  
 package org.jtheque.core.managers.core.io;
 2  
 
 3  
 /*
 4  
  * This file is part of JTheque.
 5  
  *
 6  
  * JTheque is free software: you can redistribute it and/or modify
 7  
  * it under the terms of the GNU General Public License as published by
 8  
  * the Free Software Foundation, either version 3 of the License.
 9  
  *
 10  
  * JTheque is distributed in the hope that it will be useful,
 11  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13  
  * GNU General Public License for more details.
 14  
  *
 15  
  * You should have received a copy of the GNU General Public License
 16  
  * along with JTheque.  If not, see <http://www.gnu.org/licenses/>.
 17  
  */
 18  
 
 19  
 import org.jtheque.core.managers.Managers;
 20  
 import org.jtheque.core.utils.SystemProperty;
 21  
 import org.jtheque.utils.io.FileUtils;
 22  
 
 23  
 import java.io.File;
 24  
 
 25  
 /**
 26  
  * Give access to the folders of the application.
 27  
  *
 28  
  * @author Baptiste Wicht
 29  
  */
 30  0
 public final class Folders implements IFoldersContainer {
 31  
     private File applicationFolder;
 32  
     private File librariesFolder;
 33  
     private File modulesFolder;
 34  
     private File skinsFolder;
 35  
     private File logsFolder;
 36  
     private File cacheFolder;
 37  
 
 38  
     @Override
 39  
     public File getApplicationFolder() {
 40  0
         if (applicationFolder == null) {
 41  0
             applicationFolder = new File(Managers.getCore().getApplication().getFolderPath());
 42  
 
 43  0
             FileUtils.createIfNotExists(applicationFolder);
 44  
         }
 45  
 
 46  0
         return applicationFolder;
 47  
     }
 48  
 
 49  
     @Override
 50  
     public File getSkinsFolder() {
 51  0
         if (skinsFolder == null) {
 52  0
             skinsFolder = new File(getApplicationFolder(), "/skins");
 53  
 
 54  0
             FileUtils.createIfNotExists(skinsFolder);
 55  
         }
 56  
 
 57  0
         return skinsFolder;
 58  
     }
 59  
 
 60  
     @Override
 61  
     public File getLogsFolder() {
 62  0
         if (logsFolder == null) {
 63  0
             logsFolder = new File(getApplicationFolder(), "/logs");
 64  
 
 65  0
             FileUtils.createIfNotExists(logsFolder);
 66  
         }
 67  
 
 68  0
         return logsFolder;
 69  
     }
 70  
 
 71  
     @Override
 72  
     public File getLibrariesFolder() {
 73  0
         if (librariesFolder == null) {
 74  0
             librariesFolder = new File(getApplicationFolder(), "/lib");
 75  
 
 76  0
             FileUtils.createIfNotExists(librariesFolder);
 77  
         }
 78  
 
 79  0
         return librariesFolder;
 80  
     }
 81  
 
 82  
     @Override
 83  
     public File getModulesFolder() {
 84  0
         if (modulesFolder == null) {
 85  0
             modulesFolder = new File(getApplicationFolder(), "/modules");
 86  
 
 87  0
             FileUtils.createIfNotExists(modulesFolder);
 88  
         }
 89  
 
 90  0
         return modulesFolder;
 91  
     }
 92  
 
 93  
     @Override
 94  
     public File getCacheFolder() {
 95  0
         if (cacheFolder == null) {
 96  0
             cacheFolder = new File(getApplicationFolder(), "/cache");
 97  
 
 98  0
             FileUtils.createIfNotExists(cacheFolder);
 99  
         }
 100  
 
 101  0
         return cacheFolder;
 102  
     }
 103  
 
 104  
     @Override
 105  
     public String getTempFolderPath() {
 106  0
         return SystemProperty.JAVA_IO_TMP_DIR.get();
 107  
     }
 108  
 }