private static bool CheckSingleFolder(string folderPath) { string indexFileName = Path.GetFullPath(folderPath + @"\zones.idx"); if (!File.Exists(indexFileName)) { return(false); } IEnumerator <string> ppmxlFiles = PPMXLFileIterator.PPMXLFiles(folderPath); while (ppmxlFiles.MoveNext()) { if (File.Exists(ppmxlFiles.Current)) { // Some people may only have a partial version of the catalogue (e.g. Northern Hemisphere) return(true); } } return(false); }
public static void BuildFullIndex(string catalogLocation) { int idx = -1; IEnumerator <string> filesEnu = PPMXLFileIterator.PPMXLFiles(catalogLocation); string fileNameIndex = catalogLocation + "zones.idx"; if (File.Exists(fileNameIndex)) { MessageBox.Show(string.Format("Index file {0} already exists.", fileNameIndex)); return; } using (FileStream fs = new FileStream(fileNameIndex, FileMode.Create, FileAccess.Write)) using (BinaryWriter bwrt = new BinaryWriter(fs)) { while (filesEnu.MoveNext()) { string fileName = filesEnu.Current; Console.WriteLine(fileName); idx++; int[] raIdx = new int[360]; int raCurr = 0; int recNo = -1; using (FileStream fileStr = new FileStream(fileName, FileMode.Open, FileAccess.Read)) using (BinaryReader rdr = new BinaryReader(fileStr)) { byte[] header = rdr.ReadBytes(174); while (true) { recNo++; byte[] data = rdr.ReadBytes(174); if (data == null || data.Length == 0) { break; } PPMXLEntry entry = new PPMXLEntry(Encoding.ASCII.GetString(data)); int raTrunc = (int)entry.RADeg; while (raTrunc >= raCurr) { //Console.WriteLine("Index[" + raCurr.ToString() + "] = " + recNo.ToString()); if (raCurr < 360) { raIdx[raCurr] = recNo; } raCurr++; } } } while (360 > raCurr) { //Console.WriteLine("Index[" + raCurr.ToString() + "] = " + (recNo - 1).ToString()); raIdx[raCurr] = recNo - 1; raCurr++; } for (int j = 0; j < 360; j++) { bwrt.Write(raIdx[j]); } } bwrt.Flush(); } }