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); }
public void UnlockProj() { if (mProjLock == null) { return; } mProjLock.Dispose(); mProjLock = null; }
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); }
private static MagmaFileLock LockFile(string strFile) { var magmaFileLock = new MagmaFileLock(strFile); switch (magmaFileLock.GetStatus()) { case MagmaFileLock.FileLockStatus.kMFL_LockAcquired: return(magmaFileLock); case MagmaFileLock.FileLockStatus.kMFL_LockTimeout: throw new MagmaException("Project file '" + Path.GetFileName(strFile) + "' is already open in another window."); default: throw new MagmaException("There was a problem obtaining a lock on project file."); } }
public ProjectFile() { var dataStatus = Wrapper.CloneDataTemplate("rbproj", out mData); if (dataStatus != DataStatus.kSuccess) { Console.Write("CloneDataTemplate returned: " + dataStatus); Console.WriteLine(", so errors may happen in the future..."); } UpdateVersions(); mSaveStatus = SaveStatus.kNoData; mFilename = ""; mTrackCache = new Dictionary <string, TrackInfo>(); mProjLock = null; mIsDisposed = false; }
public void LockProj() { UnlockProj(); mProjLock = LockFile(mFilename); }