Exemplo n.º 1
0
        public static MountResult Create(string executablePath, out MountInfo mount)
        {
            mount = null;
            if (!File.Exists(executablePath))
            {
                return(new MountResult(MountErrorType.EXECUTABLE_NOTFOUND, Resource.Strings.MountError_EXECUTABLE_NOTFOUND.F(executablePath ?? Resource.Strings.Undefined)));
            }

            string resourcePath = Path.Combine(Path.GetDirectoryName(executablePath), RESOURCE_PATH);

            if (!File.Exists(resourcePath))
            {
                return(new MountResult(MountErrorType.RESOURCE_NOTFOUND, Resource.Strings.MountError_RESOURCE_NOTFOUND.F(resourcePath ?? Resource.Strings.Undefined)));
            }

            try
            {
                mount = new MountInfo(executablePath, resourcePath);
            }
            catch (Exception ex)
            {
                return(new MountResult(MountErrorType.RESOURCE_READ_ERROR, Resource.Strings.MountError_RESOURCE_READ_ERROR.F(RESOURCE_PATH), ex));
            }
            return(new MountResult(MountErrorType.SUCCESS));
        }
Exemplo n.º 2
0
        public static MountResult CreateFromConfig(string configPath, out MountInfo mount)
        {
            mount = null;
            if (!File.Exists(configPath))
            {
                return(new MountResult(MountErrorType.CONFIG_NOTFOUND, Resource.Strings.MountError_CONFIG_NOTFOUND.F(configPath)));
            }

            LauncherSettingsFile sFile = new LauncherSettingsFile();

            try
            {
                sFile.ReadFromFile(configPath);
            }
            catch (Exception ex)
            {
                return(new MountResult(MountErrorType.CONFIG_READ_ERROR, Resource.Strings.MountError_CONFIG_READ_ERROR, ex));
            }
            return(Create(sFile.ExecutablePath, out mount));
        }