/* Function: Open * * Attempts to open the passed configuration file and returns whether it was successful. Any errors * encountered in trying to open the file will be added to the errors array. * * Parameters: * * fileName - The <Path> of the configuration file. * propertySource - The <Config.PropertySource> this file represents. * fileFormatFlags - The <FileFormatFlags> to use when parsing the file. * errorList - A list where the parser will put any errors. */ public bool Open(Path fileName, Config.PropertySource propertySource, FileFormatFlags fileFormatFlags, ErrorList errorList) { if (IsOpen) { throw new Engine.Exceptions.FileAlreadyOpen(fileName, this.fileName); } if (!File.Exists(fileName)) { errorList.Add( Locale.Get("NaturalDocs.Engine", "ConfigFile.DoesNotExist(name)", fileName) ); return(false); } try { file = new StreamReader(fileName, System.Text.Encoding.UTF8, true); } catch (Exception e) { errorList.Add( Locale.Get("NaturalDocs.Engine", "ConfigFile.CouldNotOpen(name, exception)", fileName, e.Message) ); return(false); } this.fileName = fileName; this.propertySource = propertySource; this.fileFormatFlags = fileFormatFlags; this.errorList = errorList; this.lineNumber = 0; string identifier, valueString; if (!Get(out identifier, out valueString) || identifier.ToLower() != "format") { AddError(Locale.Get("NaturalDocs.Engine", "ConfigFile.DidntStartWithFormat(name)", fileName)); } else { version = valueString; if (version == null) { AddError(Locale.Get("NaturalDocs.Engine", "ConfigFile.FormatNotAValidVersionString(versionString)", valueString)); } } if (version != null) { return(true); } else { Close(); return(false); } }
/* Function: Open * * Attempts to open the passed configuration file and returns whether it was successful. Any errors * encountered in trying to open the file will be added to the errors array. * * Parameters: * * newFileName - The <Path> of the configuration file. * newFileFormatFlags - The <FileFormatFlags> to use when parsing the file. * newErrorList - A list where the parser will put any errors. */ public bool Open(Path newFileName, FileFormatFlags newFileFormatFlags, ErrorList newErrorList) { if (IsOpen) { throw new Engine.Exceptions.FileAlreadyOpen(newFileName, fileName); } if (!File.Exists(newFileName)) { newErrorList.Add( Locale.Get("NaturalDocs.Engine", "ConfigFile.DoesNotExist(name)", newFileName) ); return(false); } try { file = new StreamReader(newFileName, System.Text.Encoding.UTF8, true); } catch { newErrorList.Add( Locale.Get("NaturalDocs.Engine", "ConfigFile.CouldNotOpen(name)", newFileName) ); return(false); } fileName = newFileName; fileFormatFlags = newFileFormatFlags; errorList = newErrorList; lineNumber = 0; string identifier, valueString; if (!Get(out identifier, out valueString) || identifier.ToLower() != "format") { AddError(Locale.Get("NaturalDocs.Engine", "ConfigFile.DidntStartWithFormat(name)", fileName)); } else { version = valueString; if (version == null) { AddError(Locale.Get("NaturalDocs.Engine", "ConfigFile.FormatNotAValidVersionString(versionString)", valueString)); } } if (version != null) { return(true); } else { Close(); return(false); } }
public FileFormat(string id, string name, string description, FileFormatFlags flags, params GameConsole[] supportedConsoles) { m_id = id; m_name = name; m_description = description; m_flags = flags; m_supportedConsoles = new List <GameConsole>(supportedConsoles); }
public FileFormat(string name, FileFormatFlags flags, GameConsole console) : this(name, name, name, flags, console) { }
public bool HasFlag(FileFormatFlags f) { return(Flags.HasFlag(f)); }