コード例 #1
0
        public void WriteFile(string strFilename)
        {
            var flag          = !(mProjLock != null && mProjLock.GetName() == MagmaFileLock.GetLockNameFromPath(strFilename));
            var magmaFileLock = (MagmaFileLock)null;

            if (flag)
            {
                magmaFileLock = LockFile(strFilename);
            }
            Unlock();
            var fileStatus = Wrapper.WriteDtaFile(strFilename, mData);

            if (fileStatus != FileStatus.kSuccess)
            {
                if (magmaFileLock != null)
                {
                    magmaFileLock.Dispose();
                }
                throw new MagmaException("WriteDtaFile(" + strFilename + ") returned " + fileStatus + ".");
            }
            SetFilename(strFilename);
            if (magmaFileLock != null)
            {
                UnlockProj();
                mProjLock = magmaFileLock;
            }
            Lock();
            SetSaveStatus(SaveStatus.kSaved);
        }
コード例 #2
0
        public void ReadFile(string strFilename)
        {
            var flag           = !(mProjLock != null && mProjLock.GetName() == MagmaFileLock.GetLockNameFromPath(strFilename));
            var magmaFileLock1 = (MagmaFileLock)null;

            if (flag)
            {
                magmaFileLock1 = LockFile(strFilename);
            }
            IntPtr dataArray;
            var    fileStatus = Wrapper.ReadDtaFile(strFilename, out dataArray);
            var    message    = "Unknown error opening your project file " + strFilename;

            if (fileStatus != FileStatus.kSuccess)
            {
                if (magmaFileLock1 != null)
                {
                    magmaFileLock1.Dispose();
                }
                switch (fileStatus)
                {
                case FileStatus.kErrorUnknown:
                case FileStatus.kErrorDuringParse:
                case FileStatus.kErrorBadOutPtr:
                case FileStatus.kErrorBadDataArrayPtr:
                    message = "An error occurred loading your project file. Please make sure that the file is a .rbproj and is not corrupt. Attempted file: " + strFilename;
                    break;

                case FileStatus.kErrorFileNotFound:
                    message = "Project file is in use or not found\n" + strFilename;
                    break;
                }
                throw new MagmaException(message);
            }
            Wrapper.SafeRelease(ref mData);
            Unlock();
            mData = dataArray;
            SetFilename(strFilename);
            if (!PatchPreviousProjectVersions())
            {
                if (magmaFileLock1 != null)
                {
                    magmaFileLock1.Dispose();
                }
                throw new MagmaException("Unsupported rbproj version. This file is version " + Convert.ToString(GetProjectVersion()));
            }
            if (magmaFileLock1 != null)
            {
                UnlockProj();
                mProjLock = magmaFileLock1;
            }
            Lock();
            UpdateVersions();
            SetSaveStatus(SaveStatus.kSaved);
        }