Кресты / Говнокод #13947 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 62
  63. 63
  64. 64
  65. 65
  66. 66
  67. 67
  68. 68
  69. 69
  70. 70
  71. 71
  72. 72
  73. 73
  74. 74
  75. 75
  76. 76
  77. 77
  78. 78
  79. 79
  80. 80
  81. 81
  82. 82
  83. 83
  84. 84
  85. 85
  86. 86
  87. 87
  88. 88
int DataBase::split(fstream& from,fstream& from0,unsigned int p){
    int pos0 = static_cast<int>(from.tellp());
    char *a,*b;
    Data d,d0;
    Index x,x0;
    from.clear();
    from.seekp(0,ios::end);
    int PosEnd = static_cast<int>(from.tellp());
    PosEnd -=static_cast<int>(p);
    a = new char[PosEnd];
    from.seekp(p,ios::beg);
    from.read(a,PosEnd); 
    from.seekp(p+BlockSize,ios::beg);
    from.write(a,PosEnd); 
    from.seekp(p+BlockSize,ios::beg);
    b = a+5*RecordSize;
    from.write(b,RecordSize*5);
    for (int i = 0; i < 5; ++i){ 
        from << d;
    }
    from.seekp(p+RecordSize*5,ios::beg);
    for (int i = 0; i < 5; ++i){ 
        from << d;
    }
    from.seekg(p+RecordSize*4);
    from >> d;
    int newmax = d.Id(); 
    from0.seekp(0,ios::end);
    int indexend =static_cast<int>(from0.tellp());
    from0.seekg(0,ios::beg);
    while(true){ 
        from0 >> x;
        if(from0.eof())break;
        if(x.Pointer() == p){ 
            int oldpos = static_cast<int>(from0.tellp());
            oldpos++;
            int count = indexend - oldpos;
            char *c = new char[count];
            from0.seekg(1,ios::cur);
            from0.read(c,count);
            from0.seekp(oldpos,ios::beg);
            x0.Max(x.Max()); 
            x0.Num(5);
            x0.Pointer(p + BlockSize);
            from0 << x0;
            from0.write(c,count);
            from0.seekp(oldpos - IndexSize,ios::beg);
            x.Max(newmax); 
            x.Num(5);
            from0 << x;
            delete c;
            from.clear();
            from0.seekp(0,ios::beg);
            break;
        }
    }
    from.clear();
    bool first = false;
    while(true){ 
        from0 >> x;
        if(from0.eof())break;
        if(x.Pointer() > p ){
            if(!first){ 
                from0.seekp(-(IndexSize-1),ios::cur);
                from0 << x;
                int test = from0.tellp();
                from0.clear();
                first = true;
                continue;
            }
            x.Pointer(x.Pointer()+BlockSize);
            from0.seekp(-(IndexSize-1),ios::cur);
            from0 << x;
            int test = from0.tellp();
        }
        else{ 
            from0.seekp(-(IndexSize-1),ios::cur);
            from0 << x;
            int test = from0.tellp();
            from0.clear();
        }
    }
    from.clear();
    from.seekp(pos0);
    delete a;
    //delete b;
    return 0;
}

Нарезаем

Запостил: Abbath Abbath, (Updated )

Комментарии (0) RSS

Добавить комментарий

Помни, guest, за тобой могут следить!

    А не использовать ли нам bbcode?


    8