- Timestamp:
- 02/28/12 13:43:20 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/modelicaml/org.openmodelica.modelicaml.common/src/org/openmodelica/modelicaml/common/services/ModelicaMLServices.java
r1272 r1367 1 1 package org.openmodelica.modelicaml.common.services; 2 2 3 import java.io.File; 4 import java.net.URI; 3 5 import java.util.ArrayList; 4 6 import java.util.Collections; … … 7 9 import java.util.List; 8 10 11 import org.eclipse.core.filesystem.EFS; 12 import org.eclipse.core.filesystem.IFileStore; 13 import org.eclipse.core.filesystem.IFileSystem; 14 import org.eclipse.core.runtime.CoreException; 9 15 import org.eclipse.core.runtime.IAdaptable; 10 16 import org.eclipse.emf.common.util.EList; … … 151 157 } 152 158 159 160 public static List<String> getFilesToLoad(String folderAbsolutePath){ 161 162 // list of files to be loaded 163 List<String> list = new ArrayList<String>(); 164 165 // add "/" at the end if there is none 166 if (!folderAbsolutePath.trim().endsWith("/")) { 167 folderAbsolutePath = folderAbsolutePath + "/"; 168 } 169 170 File folder = new File(folderAbsolutePath); 171 if (folder.isDirectory()) { 172 /* 173 * - get all .mo files add these to the list 174 * - get all sub.folders and add sub-folder-name/package.mo to the list 175 */ 176 IFileSystem fileSystem = EFS.getLocalFileSystem(); 177 IFileStore folderStore = fileSystem.getStore(URI.create(folderAbsolutePath)); 178 179 String[] children; 180 try { 181 children = folderStore.childNames(EFS.NONE, null); 182 for (int i = 0; i < children.length; i++) { 183 String child = children[i]; 184 185 File checkChild = new File(folderAbsolutePath + child); 186 187 if (child.endsWith(".mo")) { // if it is a .mo file 188 list.add(folderAbsolutePath + child); 189 } 190 else if (checkChild.isDirectory()) { // if it is a folder 191 list.add(folderAbsolutePath + child + "/package.mo"); 192 } 193 else { // any other files 194 195 } 196 } 197 } catch (CoreException e) { 198 // TODO Auto-generated catch block 199 e.printStackTrace(); 200 } 201 } 202 return list; 203 } 204 153 205 }
Note: See TracChangeset
for help on using the changeset viewer.