/// <summary> /// ������������ ����������������� ������ ������ /// </summary> /// <param name="fullFileName">������ ��� ����� ��� ������������</param> /// <param name="fastExtraction">������������ ������� ���������� �� ����� (��� �������� CRC-64)?</param> /// <param name="runAsSeparateThread">��������� � ��������� ������?</param> /// <returns>��������� ���� ��������</returns> public bool StartToTest(String fullFileName, bool fastExtraction, bool runAsSeparateThread) { // ���� ����� ����������� ����� �������� - �� ��������� ��������� ������ if(InProcessing) { return false; } // ���������� ���� ������������ ���������� ����� �������� ������ this.processedOK = false; // ���������� ��������� ����������� ��������� ����������-������ this.finished = false; // ���� ��� ����� �� ����������� if( (fullFileName == null) || (fullFileName == "") ) { // ���������� ��������� ����������� ��������� ����������-������ this.finished = true; // ������������� ������� ���������� ��������� this.finishedEvent[0].Set(); return false; } // ���������� ��������� ���� �� ������� ����� ����� this.path = this.eFileNamer.GetPath(fullFileName); // ���������� ��������� ����� �� ������� ����� ����� this.fileName = this.eFileNamer.GetShortFileName(fullFileName); // ���� �������� ���� �� ����������, �������� �� ������ if(!File.Exists(this.path + this.fileName)) { // ���������� ��������� ����������� ��������� ����������-������ this.finished = true; // ������������� ������� ���������� ��������� this.finishedEvent[0].Set(); return false; } // ������������� �������� ��� ����� �� ����������� �������, // � � ���������� �������� ��������� "fileName", "dataCount", "eccCount", "codecType" if(!this.eFileNamer.Unpack(ref this.fileName, ref this.dataCount, ref this.eccCount, ref this.codecType)) { return false; } // ������������ ������� ���������� �� ����� (��� �������� CRC-64)? this.fastExtraction = fastExtraction; // ������������� �� ��������� this.eFileAnalyzer.OnUpdateFileAnalyzeProgress = OnUpdateFileAnalyzeProgress; this.eFileAnalyzer.OnFileAnalyzeFinish = OnFileAnalyzeFinish; this.eFileAnalyzer.OnGetDamageStat = OnGetDamageStat; // ���������, ��� ����� ������ ����������� this.exitEvent[0].Reset(); this.executeEvent[0].Set(); this.wakeUpEvent[0].Reset(); this.finishedEvent[0].Reset(); // ���� �������, ��� �� ��������� ������ � ��������� ������, // ��������� � ������ if(!runAsSeparateThread) { // ��������������� ���� �� ������������ ������ � ���������� ������ Test(); // ���������� ��������� ��������� return this.processedOK; } // ������� ����� �������������� ������... this.thrRecoveryStarCore = new Thread(new ThreadStart(Test)); //...����� ���� ��� ���... this.thrRecoveryStarCore.Name = "RecoveryStarCore.Test()"; //...������������� ��������� ��������� ������... this.thrRecoveryStarCore.Priority = this.threadPriority; //...� ��������� ��� this.thrRecoveryStarCore.Start(); // ��������, ��� ��� ��������� return true; }
/// <summary> /// ���������������� ����������� ����� �� ���� RAID /// </summary> /// <param name="fullFileName">������ ��� ����� ��� ����������������� �����������</param> /// <param name="dataCount">���������� �������� �����</param> /// <param name="eccCount">���������� ����� ��� ��������������</param> /// <param name="codecType">��� ������ ����-�������� (�� ���� �������)</param> /// <param name="runAsSeparateThread">��������� � ��������� ������?</param> /// <returns>��������� ���� ��������</returns> public bool StartToProtect(String fullFileName, int dataCount, int eccCount, int codecType, bool runAsSeparateThread) { // ���� ����� ����������� ����� �������� - �� ��������� ��������� ������ if(InProcessing) { return false; } // ���������� ���� ������������ ���������� ����� �������� ������ this.processedOK = false; // ���������� ��������� ����������� ��������� ����������-������ this.finished = false; // ���� ��� ����� �� ����������� if( (fullFileName == null) || (fullFileName == "") ) { // ���������� ��������� ����������� ��������� ����������-������ this.finished = true; // ������������� ������� ���������� ��������� this.finishedEvent[0].Set(); return false; } // ���������� ��������� ���� �� ������� ����� ����� this.path = this.eFileNamer.GetPath(fullFileName); // ���������� ��������� ����� �� ������� ����� ����� this.fileName = this.eFileNamer.GetShortFileName(fullFileName); // ���� �������� ���� �� ����������, �������� �� ������ if(!File.Exists(this.path + this.fileName)) { // ���������� ��������� ����������� ��������� ����������-������ this.finished = true; // ������������� ������� ���������� ��������� this.finishedEvent[0].Set(); return false; } // ��������� ���������� �������� ����� this.dataCount = dataCount; // ��������� ���������� ����� ��� �������������� this.eccCount = eccCount; // ��������� ��� ������ ����-�������� this.codecType = codecType; // ������������� �� ��������� this.eFileSplitter.OnUpdateFileSplittingProgress = OnUpdateFileSplittingProgress; this.eFileSplitter.OnFileSplittingFinish = OnFileSplittingFinish; this.eFileCodec.OnUpdateRSMatrixFormingProgress = OnUpdateRSMatrixFormingProgress; this.eFileCodec.OnRSMatrixFormingFinish = OnRSMatrixFormingFinish; this.eFileCodec.OnUpdateFileStreamsOpeningProgress = OnUpdateFileStreamsOpeningProgress; this.eFileCodec.OnFileStreamsOpeningFinish = OnFileStreamsOpeningFinish; this.eFileCodec.OnStartedRSCoding = OnStartedRSCoding; this.eFileCodec.OnUpdateFileCodingProgress = OnUpdateFileCodingProgress; this.eFileCodec.OnFileCodingFinish = OnFileCodingFinish; this.eFileCodec.OnUpdateFileStreamsClosingProgress = OnUpdateFileStreamsClosingProgress; this.eFileCodec.OnFileStreamsClosingFinish = OnFileStreamsClosingFinish; this.eFileAnalyzer.OnUpdateFileAnalyzeProgress = OnUpdateFileAnalyzeProgress; this.eFileAnalyzer.OnFileAnalyzeFinish = OnFileAnalyzeFinish; // ���������, ��� ����� ������ ����������� this.exitEvent[0].Reset(); this.executeEvent[0].Set(); this.wakeUpEvent[0].Reset(); this.finishedEvent[0].Reset(); // ���� �������, ��� �� ��������� ������ � ��������� ������, // ��������� � ������ if(!runAsSeparateThread) { // �������� ���� �� ����������� (�������� ���) Protect(); // ���������� ��������� ��������� return this.processedOK; } // ������� ����� ����������� ������... this.thrRecoveryStarCore = new Thread(new ThreadStart(Protect)); //...����� ���� ��� ���... this.thrRecoveryStarCore.Name = "RecoveryStarCore.Protect()"; //...������������� ��������� ��������� ������... this.thrRecoveryStarCore.Priority = this.threadPriority; //...� ��������� ��� this.thrRecoveryStarCore.Start(); // ��������, ��� ��� ��������� return true; }