]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/performance-audio-sr.git/blob - psdk_cust/pdk_k2g_1_0_1_1_eng/packages/ti/board/utils.xs
PASDK-258:Update PDK eng to 1.0.1.1. Using build number to differentiate PDK eng...
[processor-sdk/performance-audio-sr.git] / psdk_cust / pdk_k2g_1_0_1_1_eng / packages / ti / board / utils.xs
1 function getAllFiles(dir)
2 {     
3     var srcFile = [];
4     var d;
6     /* If recurse parameter is not specified we default to recursive search. */
7     //if (recurse == null)
8     var recurse = true;
10     if (dir == undefined) 
11         d = ".";
12     else 
13         d = dir;
15     /* Get access to the current directory. */
16     var file = new java.io.File(d);
18     /* Check if the file exists and it is a directory. */
19     if (file.exists() && file.isDirectory()) 
20     {
21         /* Get a list of all files in the specific directory. */
22         var fileList = file.listFiles();
23         for (var i = 0; i < fileList.length; i++) 
24         {
25             /* Dont add the generated directory 'package' and any of its files 
26              * to the list here. */
27             if ((fileList[i].getName().matches("package") == false) && (fileList[i].getName().matches(".git") == false))
28             {
29                 /* Check if the detected file is a directory */
30                 if (fileList[i].isDirectory())
31                 {
32                     /* We will recurse into the subdirectory only if required to do so. */
33                     if (recurse == true)
34                     {
35                         /* Generate the directory Name in which we will recurse. */ 
36                         var directoryName = d + "/" + fileList[i].getName();
38                         /* Get a list of all files in this directory */
39                         var fileListing = getAllFiles(directoryName);
40                         if (fileListing != null)
41                         {
42                             /* Return a list of all file names in the directory. */
43                             for (var j = 0 ; j < fileListing.length; j++) 
44                                 srcFile[srcFile.length++] = fileListing[j];
45                         }
46                     }
47                 }
48                 else
49                 {
50                     /* This was a file. Check if the file name matches the extension */
51                     //if (fileList[i].getName().endsWith(ext) == true)
52                     srcFile[srcFile.length++] = d + "/" + fileList[i].getName();
53                 }
54             }
55         }
57         return srcFile;
58     }
59     return null;
60 }