/// <summary> /// This function takes a string that points to a Day folder 'folder' and returns all the hour folders. /// The dayStartUnixTime is the UnixTime of the year-month-day /// combination from the Day folder. /// </summary> /// <param name="folder"></param> /// <param name="dayStartUnixTime"></param> /// <returns></returns> private static HourFolderNode[] GetHourFolderInformation(string folder, double dayStartUnixTime) { if (folder == null || folder.Length < 1) { return(null); } FileSystemInfo[] fi = null; FileSystemInfo[] fia = null; DirectoryInfo di = null; HourFolderNode[] ret; //Get the directory info based on the path di = new DirectoryInfo(folder); fi = di.GetFileSystemInfos(HourFolderNode.HOUR_FOLDER_SP); if (fi == null || fi.Length == 0) { //The directory does not have hour information return(null); } Array.Sort(fi, new FileSystemInfoNameComparer()); ret = new HourFolderNode[fi.Length]; int ind = 0; foreach (FileSystemInfo fsi in fi) { //Get the directory info based on the path di = new DirectoryInfo(fsi.FullName); //Find any data files in the specified directory fia = di.GetFileSystemInfos(); if (fia == null || fia.Length == 0) { //The passed directory does not suit our needs continue; } ret[ind] = new HourFolderNode(); ret[ind].folderName = fsi.FullName; try { ret[ind].hour = Int32.Parse(fsi.Name); } catch { } ret[ind].startUnixTime = dayStartUnixTime + (ret[ind].hour * WocketsTimer.MilliInHour); ret[ind].endUnixTime = ret[ind].startUnixTime + WocketsTimer.MilliInHour - 1; ind++; } return(ret); }
/// <summary> /// This function takes a string that points to a Day folder 'folder' and returns all the hour folders that /// have a file in them that matches 'fileRegex'. The dayStartUnixTime is the UnixTime of the year-month-day /// combination from the Day folder. /// </summary> /// <param name="folder"></param> /// <param name="dayStartUnixTime"></param> /// <param name="fileRegex"></param> /// <returns></returns> private static HourFolderNode[] GetHourFolderInformation(string folder, double dayStartUnixTime, string fileRegex) { if (folder == null || folder.Length < 1) return null; FileSystemInfo[] fi = null; FileSystemInfo[] fia = null; DirectoryInfo di = null; HourFolderNode[] ret; //Get the directory info based on the path di = new DirectoryInfo(folder); fi = di.GetFileSystemInfos(HourFolderNode.HOUR_FOLDER_SP); if (fi == null || fi.Length == 0) { //The directory does not have hour information return null; } ret = new HourFolderNode[fi.Length]; int ind = 0; foreach (FileSystemInfo fsi in fi) { //Get the directory info based on the path di = new DirectoryInfo(fsi.FullName); //Find any data files in the specified directory fia = di.GetFileSystemInfos(fileRegex); if (fia == null || fia.Length == 0) { //The passed directory does not suit our needs continue; } ret[ind] = new HourFolderNode(); ret[ind].folderName = fsi.FullName; try { ret[ind].hour = Int32.Parse(fsi.Name); } catch { } ret[ind].startUnixTime = dayStartUnixTime + (ret[ind].hour * WocketsTimer.MilliInHour); ret[ind].endUnixTime = ret[ind].startUnixTime + WocketsTimer.MilliInHour - 1; ind++; } return ret; }