Copying files with CHDangerous

Discussion in 'CommandHelper' started by Oboist, Jan 24, 2018.

  1. Oboist

    Oboist Member


    I was trying to write a simple script that makes backups. Main server world is > 8gb now but i still want to have backups... at least for central territories.

    /backup = >>>
    @rgdir = '../../world/region/'
    @bdir = '../../backups/'.simple_date('yy-MM-dd').'/'
    for(@x = -10, @x <= 10, @x++){
        for(@y = -10, @y <= 10, @y++){
            @filename = 'r.'[email protected]x.'.'[email protected]y.'.mca'
            if(file_size(@rgdir[email protected]filename) != 0){
                @file = read(@rgdir[email protected]filename)
                chd_write(@bdir[email protected]filename, @file)
                console(@filename, false)
    console('DONE!', false)
    It makes copies... kinda. Files in backups/ are twice as bigger than originals and cannot be opened correctly...
    What have i done wrong?
  2. PseudoKnight

    PseudoKnight Well-Known Member Developer

    You want to copy files, not read them in as text and then write them back into a file. CHDangerous cannot do that. Try CHFiles.
  3. Oboist

    Oboist Member

    Oh, thanks, it works!
    As i see, it already have all write/read procedures, so i no longer need CHDangerous...