SHARE
TWEET

Untitled

a guest Dec 8th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int SelenaJobsManager::RestoryJ(SelenaJob& J, char stage)
  2. {
  3.     if (!J.storageName.length())
  4.         return -1;
  5.  
  6.     std::ifstream f;
  7.     std::string   sn;
  8.  
  9.     if (stage == 1)
  10.         goto m_current;
  11.     if (stage == 2)
  12.         goto m_results;
  13.  
  14.     FullStorageName(J.storageName, sn);
  15.     sn += ".job";
  16.  
  17.     // RU. ������� ������ ������� �� ���������� ������.
  18.     // EN. Attempt to read job assignment.
  19.     f.open(sn, std::ios::out | std::ios::binary);
  20.     if (!f.is_open()) {
  21. m_current:;
  22.         // RU. ������� ������ ������� ������.
  23.         // EN. Attempt to read current job.
  24.         sn = ("_" + J.storageName);
  25.         FullStorageName(sn, sn);
  26.         sn += ".job";
  27.         f.open(sn, std::ios::out | std::ios::binary);
  28.         if (!f.is_open()) {
  29. m_results:;
  30.             // RU. ������� ������ ����������� ����������� ������.
  31.             // EN. An attempt to read the results of the  performed work
  32.             sn = ("__" + J.storageName);
  33.             FullStorageName(sn, sn);
  34.             sn += ".job";
  35.             f.open(sn, std::ios::out | std::ios::binary);
  36.     }   }
  37.     if (!f.is_open()) return -1;
  38.  
  39.     SelenaJob JR;
  40.     JR.storageName = J.storageName;
  41.  
  42.     f.read(reinterpret_cast<char*>(&JR.stage), sizeof(J.stage));
  43.     f.read(reinterpret_cast<char*>(&JR.completCode), sizeof(J.completCode));
  44.  
  45.     f.read(reinterpret_cast<char*>(&JR.h), sizeof(J.h));
  46.  
  47.     char* buf = nullptr;
  48.     int   n = 0;
  49.     ReadNameString(f, &buf, n, JR.command);
  50.     ReadNameString(f, &buf, n, JR.fileInputName);
  51.     ReadNameString(f, &buf, n, JR.fileOutputName);
  52.     ReadNameString(f, &buf, n, JR.errorMessage);
  53.  
  54.     J = JR;
  55.  
  56.     return 0;
  57. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top