コード例 #1
0
ファイル: rest.php プロジェクト: Jaesin/zim-web
 public function libdeletestl()
 {
     $cr = ERROR_OK;
     $id = NULL;
     $this->load->helper('printerstoring');
     if ($_SERVER['REQUEST_METHOD'] == 'GET') {
         if ($id = $this->input->get('id')) {
             if (intval($id) < 1) {
                 $cr = ERROR_WRONG_PRM;
             } else {
                 $cr = PrinterStoring_deleteStl(intval($id));
             }
         } else {
             $cr = ERROR_MISS_PRM;
         }
         $this->_return_cr($cr);
     }
     return;
 }
コード例 #2
0
function PrinterStoring_storeStl($name, $f1, $f2)
{
    global $CFG;
    $CI =& get_instance();
    $stl_library_path = $CFG->config['stl_library'];
    // check if library folder exist
    if (@is_dir($stl_library_path) == false) {
        $CI->load->helper('printerlog');
        PrinterLog_logError('stl library folder does not exist', __FILE__, __LINE__);
        return ERROR_INTERNAL;
    }
    // get last unused ID
    if (($model_id = PrinterStoring__getLastId($stl_library_path)) < 0) {
        $CI->load->helper('printerlog');
        PrinterLog_logError('could not get the last id from stl library', __FILE__, __LINE__);
        return ERROR_INTERNAL;
    }
    // create model folder
    $model_folder = $stl_library_path . sprintf('%06d', $model_id) . '/';
    if (@mkdir($model_folder) == false) {
        $CI->load->helper('printerlog');
        PrinterLog_logError('could not create the model folder : ' . $model_folder, __FILE__, __LINE__);
        return ERROR_DISK_FULL;
    }
    // create info file
    $info_file = $model_folder . PRINTERSTORING_FILE_INFO_JSON;
    $info = array("id" => $model_id, "name" => $name, PRINTERSTORING_TITLE_CREATE_DATE => date("Y-m-d"), PRINTERSTORING_TITLE_MULTI_STL => $f2 === NULL ? false : true);
    if (!PrinterStoring__createInfoFile($info_file, $info)) {
        PrinterStoring_deleteStl($model_id);
        $CI->load->helper('printerlog');
        PrinterLog_logError('could not create the model info file', __FILE__, __LINE__);
        return ERROR_DISK_FULL;
    }
    // store rendering image
    if (!PrinterStoring__storeRendering($f1, $f2, $model_folder . PRINTERSTORING_FILE_IMG_PNG)) {
        PrinterStoring_deleteStl($model_id);
        $CI->load->helper('printerlog');
        PrinterLog_logError('could not store the rendering image', __FILE__, __LINE__);
        return ERROR_INTERNAL;
    }
    // store file(s)
    if (!PrinterStoring__storeModelFile($model_folder . PRINTERSTORING_FILE_STL1_BZ2, $f1["full_path"]) || $f2 !== NULL && !PrinterStoring__storeModelFile($model_folder . PRINTERSTORING_FILE_STL2_BZ2, $f2["full_path"])) {
        PrinterStoring_deleteStl($model_id);
        $CI->load->helper('printerlog');
        PrinterLog_logError('could not store the file(s)', __FILE__, __LINE__);
        return ERROR_DISK_FULL;
    }
    // check disk free space
    if (!PrinterStoring__checkFreeSpace()) {
        PrinterStoring_deleteStl($model_id);
        return ERROR_DISK_FULL;
    }
    //stats info
    $CI->load->helper('printerlog');
    PrinterLog_statsLibrarySTL(PRINTERLOG_STATS_LABEL_LOAD, $f2 === NULL ? 1 : 2);
    return ERROR_OK;
}