void Color::LoadICCProfiles() { if(m_iccSearchPaths!= NULL){ delete m_iccSearchPaths; } const Int32 NUMSEARCHPATHS = 4; m_iccSearchPaths = new String[NUMSEARCHPATHS]; Filename cmykDir = GeGetPluginPath(); cmykDir += Filename(String("cmyk")); m_iccSearchPaths[0] = cmykDir.GetString(); m_iccSearchPaths[1] = "/Library/ColorSync/Profiles/"; m_iccSearchPaths[2] = "/Users/vidarn/Library/ColorSync"; m_iccSearchPaths[3] = "C:\\Windows\\System32\\Spool\\Drivers\\Color\\"; Logger::AddLine("Creating LAB profile",1); m_LABProfile = cmsCreateLab4Profile(NULL); Logger::AddLine("Creating default sRGB profile",1); m_displayProfile = cmsCreate_sRGBProfile(); m_RGBProfiles.Insert(vnColorProfile("sRGB",m_displayProfile),0); for(Int32 i=0;i<NUMSEARCHPATHS;++i){ BrowseFiles* bf = BrowseFiles::Alloc(); Filename dir(m_iccSearchPaths[i]); bf->Init(dir,FALSE); int RGBPos = m_RGBProfiles.GetCount(); int CMYKPos = m_CMYKProfiles.GetCount(); int spotPos = m_spotProfiles.GetCount(); if (bf) { while (bf->GetNext()) { Filename fileName = bf->GetFilename(); fileName.SetDirectory(dir); String str = fileName.GetString(); Char *buffer = new Char[str.GetCStringLen()+1]; str.GetCString(buffer,str.GetCStringLen()+1); Logger::AddLine(buffer,1); cmsHPROFILE profile = cmsOpenProfileFromFile(buffer, "r"); if(profile != NULL){ cmsColorSpaceSignature sig = cmsGetColorSpace(profile); Int32 length = cmsGetProfileInfoASCII(profile,cmsInfoDescription,"en","US",NULL,0); Char *buffer2 = new Char[length]; cmsGetProfileInfoASCII(profile,cmsInfoDescription,"en","US",buffer2,length); String info(buffer2); int pt = _cmsLCMScolorSpace(sig); if(PT_RGB == pt){ Logger::AddLine("RGB profile",1); m_RGBProfiles.Insert(vnColorProfile(info,profile),RGBPos); RGBPos++; } if(PT_CMYK == pt){ cmsHTRANSFORM xform = cmsCreateTransform(profile,TYPE_NAMED_COLOR_INDEX,m_displayProfile,TYPE_RGB_DBL,INTENT_PERCEPTUAL,0); if(xform != NULL){ cmsNAMEDCOLORLIST* colorList = cmsGetNamedColorList(xform); if(colorList != NULL){ m_spotProfiles.Insert(vnColorProfile(info,profile),spotPos); spotPos++; } else{ Logger::AddLine("CMYK profile",1); m_CMYKProfiles.Insert(vnColorProfile(info,profile),CMYKPos); CMYKPos++; } cmsDeleteTransform(xform); } } delete buffer2; } else { Logger::AddLine("Invalid",1); } delete buffer; } } BrowseFiles::Free(bf); } }
void PlanPrep::Program_Control (void) { int i, dump; char *str_ptr; Sort_Type input_sort; //---- open network files ---- Demand_Service::Program_Control (); //---- open the input plans ---- if (Get_Control_String (NODE_LIST_PATHS) != NULL) { type_flag = Get_Control_Flag (NODE_LIST_PATHS); } str_ptr = Get_Control_String (INPUT_PLAN_FILE); if (str_ptr == NULL) goto control_error; input_plans.File_Type ("Input Plan File"); str_ptr = Project_Filename (str_ptr, Extension ()); Print_Filename (2, input_plans.File_Type (), str_ptr); input_plans.Filename (str_ptr); str_ptr = Get_Control_String (INPUT_PLAN_FORMAT); if (str_ptr != NULL) { input_plans.File_Format (str_ptr); Print (1, "%s Format = %s", input_plans.File_Type (), str_ptr); } input_plans.Node_Based_Flag (type_flag); if (!input_plans.Open (0)) { File_Error ("Opening Input Plan File", input_plans.Filename ()); } type_flag = input_plans.Node_Based_Flag (); parts_flag = (input_plans.Extend () > 0); //---- input plan sort ---- str_ptr = Get_Control_String (INPUT_PLAN_SORT); if (str_ptr != NULL) { Print (1, "Input Plan Sort = %s", str_ptr); if (str_cmp (str_ptr, "TRAVELER") == 0) { input_sort = TRAVELER_SORT; } else if (str_cmp (str_ptr, "TIME") == 0) { input_sort = TIME_SORT; } else { Error ("Unrecognized Input Plan Sort = %s", str_ptr); } input_plans.Plan_Sort (input_sort); input_sort_flag = true; } else { input_sort = input_plans.Plan_Sort (); } //---- open the merge plans ---- str_ptr = Get_Control_String (MERGE_PLAN_FILE); if (str_ptr != NULL) { merge_plans.File_Type ("Merge Plan File"); str_ptr = Project_Filename (str_ptr, Extension ()); Print_Filename (2, merge_plans.File_Type (), str_ptr); merge_plans.Filename (str_ptr); merge_plans.Extend (input_plans.Extend ()); str_ptr = Get_Control_String (MERGE_PLAN_FORMAT); if (str_ptr != NULL) { merge_plans.File_Format (str_ptr); Print (1, "%s Format = %s", merge_plans.File_Type (), str_ptr); } merge_plans.Node_Based_Flag (type_flag); if (!merge_plans.Open (0)) { File_Error ("Opening Merge Plan File", merge_plans.Filename ()); } merge_flag = true; if (merge_plans.Node_Based_Flag () != type_flag) { Error ("Incompatible Plan Formats"); } } //---- open the subarea plans ---- str_ptr = Get_Control_String (SUBAREA_PLAN_FILE); if (str_ptr != NULL) { if (merge_flag) { Error ("Merge and Subarea Plans are Incompatible"); } subarea_plans.File_Type ("Subarea Plan File"); str_ptr = Project_Filename (str_ptr); subarea_plans.Filename (str_ptr); if (subarea_plans.Extend () > 0) { if (parts_flag) { subpart_flag = true; } else { str_ptr = subarea_plans.Pathname (); str_ptr = Project_Filename (str_ptr, Extension ()); subarea_plans.Filename (str_ptr); subarea_plans.Extend (0); } } Print_Filename (2, subarea_plans.File_Type (), str_ptr); str_ptr = Get_Control_String (SUBAREA_PLAN_FORMAT); if (str_ptr != NULL) { subarea_plans.File_Format (str_ptr); Print (1, "%s Format = %s", subarea_plans.File_Type (), str_ptr); } subarea_plans.Node_Based_Flag (type_flag); if (!subarea_plans.Open (0)) { File_Error ("Opening Subarea Plan File", subarea_plans.Filename ()); } subarea_flag = true; if (subarea_plans.Node_Based_Flag () != type_flag) { Error ("Incompatible Plan Formats"); } } //---- open the output plans ---- str_ptr = Get_Control_String (OUTPUT_PLAN_FILE); if (str_ptr != NULL) { output_plans.File_Type ("Output Plan File"); str_ptr = Project_Filename (str_ptr, Extension ()); Print_Filename (2, output_plans.File_Type (), str_ptr); output_plans.Filename (str_ptr); output_plans.File_Access (CREATE); str_cpy (output_name, sizeof (output_name), output_plans.Pathname ()); extend = output_plans.Extend (); output_flag = true; str_ptr = Get_Control_String (OUTPUT_PLAN_FORMAT); if (str_ptr != NULL) { output_plans.File_Format (str_ptr); Print (1, "%s Format = %s", output_plans.File_Type (), str_ptr); binary_flag = (output_plans.File_Format () == BINARY); } output_plans.Node_Based_Flag (type_flag); } else if (merge_flag) { Error ("Plan Merging Requires an Output File"); } else if (subarea_flag) { Error ("Subarea Merging Requires an Output File"); } //---- plan sort option ---- str_ptr = Get_Control_String (PLAN_SORT_OPTION); if (str_ptr != NULL && output_flag) { Print (2, "Plan Sort Option = %s", str_ptr); if (str_cmp (str_ptr, "TRAVELER") == 0) { sort = TRAVELER_SORT; } else if (str_cmp (str_ptr, "TIME") == 0) { if (merge_flag) { Error ("Plan Merging must be performed in TRAVELER Sort"); } sort = TIME_SORT; } else { Error ("Unrecognized Plan Sort Option = %s", str_ptr); } if (!input_sort_flag || input_sort != sort) { input_plans.Plan_Memory (ALLOCATE_MEMORY); input_plans.Plan_Sort (sort); sort_flag = true; } if (sort_flag && subarea_flag) { Error ("Sorting and Subarea Merging are Incompatible"); } } //---- plan combine option ---- str_ptr = Get_Control_String (PLAN_COMBINE_OPTION); if (str_ptr != NULL && parts_flag && output_flag) { Print (2, "Plan Combine Option = %s", str_ptr); if (!input_sort_flag && !sort_flag) { Error ("The Input Sort or Sort Option are needed for Plan Combining"); } if (str_cmp (str_ptr, "FILE") == 0) { combine = FILE_COMBINE; } else if (str_cmp (str_ptr, "MEMORY") == 0) { if (merge_flag) { Error ("Plan Merging and Memory Combining are Incompatible"); } else if (subarea_flag) { Error ("Subarea Merging and Memory Combining are Incompatible"); } if (sort_flag) { combine = MEMORY_COMBINE; } else { combine = FILE_COMBINE; } } else { Error ("Unrecognized Plan Combine Option = %s", str_ptr); } combine_flag = true; } //---- max plan size ---- str_ptr = Get_Control_String (MAX_OUTPUT_PLAN_SIZE); if (str_ptr != NULL && (combine_flag || (!parts_flag && output_flag))) { Print (2, "Maximum Output Plan Size = %s megabytes", str_ptr); max_size = atol (str_ptr); if (max_size < 1 || max_size > 2048) { Error ("Maximum Output Plan Size %d is Out of Range (1-2048)", max_size); } max_size *= 1024 * 1024; max_size_flag = true; } //---- get the select traveler range ---- str_ptr = Get_Control_String (SELECT_TRAVELER_RANGE); if (str_ptr != NULL) { Print (2, "Select Traveler Range = %s", str_ptr); if (!hhold_range.Add_Ranges (str_ptr)) { Error ("Select Traveler Range", str_ptr); } hhold_flag = true; } //---- get the select time periods ---- str_ptr = Get_Control_String (SELECT_TIME_PERIODS); if (str_ptr != NULL) { Print (2, "Select Time Periods = %s", str_ptr); time_period.Format (Time_Step::HOURS); if (!time_period.Add_Ranges (str_ptr)) { File_Error ("Time Period Range", str_ptr); } time_flag = true; } //---- read the selection percentage ---- str_ptr = Get_Control_String (SELECTION_PERCENTAGE); if (str_ptr != NULL) { if (input_sort != TRAVELER_SORT) { Error ("The Input Plans must be in Traveler order for Plan Selection"); } Get_Double (str_ptr, &percent); if (percent < 0.1 || percent > 100.0) { Error ("Selection Percentage %.2lf is Out of Range (0.1-100.0)", percent); } Print (2, "Selection Percentage = %.2lf", percent); percent /= 100.0; select_flag = (percent != 1.0); } if ((time_flag || select_flag || hhold_flag) && subarea_flag) { Error ("Subarea Merging and Plan Selections are Incompatible"); } //---- check plan partitions ---- str_ptr = Get_Control_String (CHECK_PLAN_PARTITIONS); if (str_ptr != NULL) { check_flag = Get_Control_Flag (CHECK_PLAN_PARTITIONS); Print (2, "Check Plan Partitions = %s", str_ptr); if (check_flag) { partition.Initialize (sizeof (Partition)); } } //---- update plan partitions ---- str_ptr = Get_Control_String (UPDATE_PLAN_PARTITIONS); if (str_ptr != NULL) { partition_flag = Get_Control_Flag (UPDATE_PLAN_PARTITIONS); Print (2, "Update Plan Partitions = %s", str_ptr); } //---- get the household list file ---- str_ptr = Get_Control_String (HOUSEHOLD_LIST); if (str_ptr != NULL) { hhlist_file.File_Type ("Household List"); hhlist_file.Filename (Project_Filename (str_ptr)); Print_Filename (2, hhlist_file.File_Type (), str_ptr); if (!hhlist_file.Open (0)) { File_Error ("Opening Household List File", hhlist_file.Filename ()); } hhlist_flag = true; } else if (partition_flag) { Error ("Household Lists are required for Partition Updates"); } if (hhlist_flag) { combine_flag = false; if (sort_flag) { Error ("Plan Sorting and Household Lists are Incompatible"); } if (merge_flag) { Error ("Plan Merging and Household Lists are Incompatible"); } else if (subarea_flag) { Error ("Subarea Merging and Household Lists are Incompatible"); } if (check_flag) { Error ("Checking and Updating Plan Partitions are Incompatible"); } if (!output_flag) { Error ("Output Plans are Required for Household Lists"); } partition.Initialize (sizeof (Partition)); } //---- get the delete household list file ---- str_ptr = Get_Control_String (DELETE_HOUSEHOLD_LIST); if (str_ptr != NULL) { delete_file.File_Type ("Delete Household List"); delete_file.Filename (Project_Filename (str_ptr)); Print_Filename (2, delete_file.File_Type (), str_ptr); if (!delete_file.Open (0)) { File_Error ("Opening Delete Household List File", delete_file.Filename ()); } delete_flag = true; } //---- get the delete one leg plans flag ---- str_ptr = Get_Control_String (DELETE_ONE_LEG_PLANS); if (str_ptr != NULL) { one_leg_flag = Get_Control_Flag (DELETE_ONE_LEG_PLANS); Print (1, "Delete One Leg Plans = %s", str_ptr); } //---- get the fix plan file ---- str_ptr = Get_Control_String (FIX_PLAN_FILE); if (str_ptr != NULL) { fix_file.File_Type ("Fix Plan File"); if (!fix_file.Open (Project_Filename (str_ptr))) { File_Error ("Opening Fix Plan File", fix_file.Filename ()); } fix_flag = true; } //---- merge by trip ---- str_ptr = Get_Control_String (MERGE_BY_TRIP); if (str_ptr != NULL) { trip_flag = Get_Control_Flag (MERGE_BY_TRIP); Print (2, "Merge by Trip = %s", str_ptr); } //---- random number seed ---- if (select_flag || fix_flag) { str_ptr = Get_Control_String (RANDOM_NUMBER_SEED); if (str_ptr != NULL) { random.Seed (atoi (str_ptr)); } Print (2, "Random Number Seed = %d", random.Seed ()); } //---- check output file name ---- if (output_flag) { output_plans.Plan_Sort (input_plans.Plan_Sort ()); if (max_size_flag || !combine_flag) { extend = output_plans.Extend (input_plans.Extend ()); if (extend == 0 && max_size_flag) { extend = output_plans.Extend (1); } } if (!hhlist_flag || !delete_flag) { if (!output_plans.Open (0)) { File_Error ("Creating Output Plan File", output_plans.Filename ()); } } if (combine_flag && combine == FILE_COMBINE && (sort_flag || merge_flag || subarea_flag)) { //---- set the temporary output filename ---- output_plans.Filename (Filename (output_name, TEMP_LABEL)); output_plans.Extend (input_plans.Extend ()); output_plans.File_Format (BINARY); } } //---- read report types ---- compare_flag = path_flag = false; dump_path = dump_time = MAX_INTEGER; for (i=First_Report (); i != 0; i=Next_Report ()) { if (i != FIX_PLAN) compare_flag = true; if (i == PATH_CHANGE || i == DUMP_PATH_CHANGES) { path_flag = true; if (i == DUMP_PATH_CHANGES) { dump = (int) (Report_Data () * NUM_CHANGE_BINS / 100.0 + 0.5); if (dump < dump_path) { dump_path = dump; } } } else if (i == DUMP_TIME_CHANGES) { dump = (int) (Report_Data () * NUM_CHANGE_BINS / 100.0 + 0.5); if (dump < dump_time) { dump_time = dump; } } } if (compare_flag) { if (!merge_flag) { Write (1); Warning ("Change Reports require a Merge Plan File"); compare_flag = false; } memset (time_changes, '\0', sizeof (time_changes)); memset (path_changes, '\0', sizeof (path_changes)); increment = MIDNIGHT / TOTAL_TIME_PERIOD; } return; //---- error message ---- control_error: Error ("Missing Control Key = %s", Current_Key ()); }
s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _BufferInSize, u32 _BufferOut, u32 _BufferOutSize) { switch (_Parameter) { case IOCTL_GET_STATS: { if (_BufferOutSize < 0x1c) return -1017; WARN_LOG(WII_IPC_FILEIO, "FS: GET STATS - returning static values for now"); NANDStat fs; //TODO: scrape the real amounts from somewhere... fs.BlockSize = 0x4000; fs.FreeUserBlocks = 0x5DEC; fs.UsedUserBlocks = 0x1DD4; fs.FreeSysBlocks = 0x10; fs.UsedSysBlocks = 0x02F0; fs.Free_INodes = 0x146B; fs.Used_Inodes = 0x0394; *(NANDStat*)Memory::GetPointer(_BufferOut) = fs; return FS_RESULT_OK; } break; case IOCTL_CREATE_DIR: { _dbg_assert_(WII_IPC_FILEIO, _BufferOutSize == 0); u32 Addr = _BufferIn; u32 OwnerID = Memory::Read_U32(Addr); Addr += 4; u16 GroupID = Memory::Read_U16(Addr); Addr += 2; std::string DirName(HLE_IPC_BuildFilename((const char*)Memory::GetPointer(Addr), 64)); Addr += 64; Addr += 9; // owner attribs, permission u8 Attribs = Memory::Read_U8(Addr); INFO_LOG(WII_IPC_FILEIO, "FS: CREATE_DIR %s, OwnerID %#x, GroupID %#x, Attributes %#x", DirName.c_str(), OwnerID, GroupID, Attribs); DirName += DIR_SEP; File::CreateFullPath(DirName); _dbg_assert_msg_(WII_IPC_FILEIO, File::IsDirectory(DirName), "FS: CREATE_DIR %s failed", DirName.c_str()); return FS_RESULT_OK; } break; case IOCTL_SET_ATTR: { u32 Addr = _BufferIn; u32 OwnerID = Memory::Read_U32(Addr); Addr += 4; u16 GroupID = Memory::Read_U16(Addr); Addr += 2; std::string Filename = HLE_IPC_BuildFilename((const char*)Memory::GetPointer(_BufferIn), 64); Addr += 64; u8 OwnerPerm = Memory::Read_U8(Addr); Addr += 1; u8 GroupPerm = Memory::Read_U8(Addr); Addr += 1; u8 OtherPerm = Memory::Read_U8(Addr); Addr += 1; u8 Attributes = Memory::Read_U8(Addr); Addr += 1; INFO_LOG(WII_IPC_FILEIO, "FS: SetAttrib %s", Filename.c_str()); DEBUG_LOG(WII_IPC_FILEIO, " OwnerID: 0x%08x", OwnerID); DEBUG_LOG(WII_IPC_FILEIO, " GroupID: 0x%04x", GroupID); DEBUG_LOG(WII_IPC_FILEIO, " OwnerPerm: 0x%02x", OwnerPerm); DEBUG_LOG(WII_IPC_FILEIO, " GroupPerm: 0x%02x", GroupPerm); DEBUG_LOG(WII_IPC_FILEIO, " OtherPerm: 0x%02x", OtherPerm); DEBUG_LOG(WII_IPC_FILEIO, " Attributes: 0x%02x", Attributes); return FS_RESULT_OK; } break; case IOCTL_GET_ATTR: { _dbg_assert_msg_(WII_IPC_FILEIO, _BufferOutSize == 76, " GET_ATTR needs an 76 bytes large output buffer but it is %i bytes large", _BufferOutSize); u32 OwnerID = 0; u16 GroupID = 0x3031; // this is also known as makercd, 01 (0x3031) for nintendo and 08 (0x3038) for MH3 etc std::string Filename = HLE_IPC_BuildFilename((const char*)Memory::GetPointer(_BufferIn), 64); u8 OwnerPerm = 0x3; // read/write u8 GroupPerm = 0x3; // read/write u8 OtherPerm = 0x3; // read/write u8 Attributes = 0x00; // no attributes if (File::IsDirectory(Filename)) { INFO_LOG(WII_IPC_FILEIO, "FS: GET_ATTR Directory %s - all permission flags are set", Filename.c_str()); } else { if (File::Exists(Filename)) { INFO_LOG(WII_IPC_FILEIO, "FS: GET_ATTR %s - all permission flags are set", Filename.c_str()); } else { INFO_LOG(WII_IPC_FILEIO, "FS: GET_ATTR unknown %s", Filename.c_str()); return FS_FILE_NOT_EXIST; } } // write answer to buffer if (_BufferOutSize == 76) { u32 Addr = _BufferOut; Memory::Write_U32(OwnerID, Addr); Addr += 4; Memory::Write_U16(GroupID, Addr); Addr += 2; memcpy(Memory::GetPointer(Addr), Memory::GetPointer(_BufferIn), 64); Addr += 64; Memory::Write_U8(OwnerPerm, Addr); Addr += 1; Memory::Write_U8(GroupPerm, Addr); Addr += 1; Memory::Write_U8(OtherPerm, Addr); Addr += 1; Memory::Write_U8(Attributes, Addr); Addr += 1; } return FS_RESULT_OK; } break; case IOCTL_DELETE_FILE: { _dbg_assert_(WII_IPC_FILEIO, _BufferOutSize == 0); int Offset = 0; std::string Filename = HLE_IPC_BuildFilename((const char*)Memory::GetPointer(_BufferIn+Offset), 64); Offset += 64; if (File::Delete(Filename)) { INFO_LOG(WII_IPC_FILEIO, "FS: DeleteFile %s", Filename.c_str()); } else if (File::DeleteDir(Filename)) { INFO_LOG(WII_IPC_FILEIO, "FS: DeleteDir %s", Filename.c_str()); } else { WARN_LOG(WII_IPC_FILEIO, "FS: DeleteFile %s - failed!!!", Filename.c_str()); } return FS_RESULT_OK; } break; case IOCTL_RENAME_FILE: { _dbg_assert_(WII_IPC_FILEIO, _BufferOutSize == 0); int Offset = 0; std::string Filename = HLE_IPC_BuildFilename((const char*)Memory::GetPointer(_BufferIn+Offset), 64); Offset += 64; std::string FilenameRename = HLE_IPC_BuildFilename((const char*)Memory::GetPointer(_BufferIn+Offset), 64); Offset += 64; // try to make the basis directory File::CreateFullPath(FilenameRename); // if there is already a file, delete it if (File::Exists(Filename) && File::Exists(FilenameRename)) { File::Delete(FilenameRename); } // finally try to rename the file if (File::Rename(Filename, FilenameRename)) { INFO_LOG(WII_IPC_FILEIO, "FS: Rename %s to %s", Filename.c_str(), FilenameRename.c_str()); } else { ERROR_LOG(WII_IPC_FILEIO, "FS: Rename %s to %s - failed", Filename.c_str(), FilenameRename.c_str()); return FS_FILE_NOT_EXIST; } return FS_RESULT_OK; } break; case IOCTL_CREATE_FILE: { _dbg_assert_(WII_IPC_FILEIO, _BufferOutSize == 0); u32 Addr = _BufferIn; u32 OwnerID = Memory::Read_U32(Addr); Addr += 4; u16 GroupID = Memory::Read_U16(Addr); Addr += 2; std::string Filename(HLE_IPC_BuildFilename((const char*)Memory::GetPointer(Addr), 64)); Addr += 64; u8 OwnerPerm = Memory::Read_U8(Addr); Addr++; u8 GroupPerm = Memory::Read_U8(Addr); Addr++; u8 OtherPerm = Memory::Read_U8(Addr); Addr++; u8 Attributes = Memory::Read_U8(Addr); Addr++; INFO_LOG(WII_IPC_FILEIO, "FS: CreateFile %s", Filename.c_str()); DEBUG_LOG(WII_IPC_FILEIO, " OwnerID: 0x%08x", OwnerID); DEBUG_LOG(WII_IPC_FILEIO, " GroupID: 0x%04x", GroupID); DEBUG_LOG(WII_IPC_FILEIO, " OwnerPerm: 0x%02x", OwnerPerm); DEBUG_LOG(WII_IPC_FILEIO, " GroupPerm: 0x%02x", GroupPerm); DEBUG_LOG(WII_IPC_FILEIO, " OtherPerm: 0x%02x", OtherPerm); DEBUG_LOG(WII_IPC_FILEIO, " Attributes: 0x%02x", Attributes); // check if the file already exist if (File::Exists(Filename)) { WARN_LOG(WII_IPC_FILEIO, "\tresult = FS_RESULT_EXISTS"); return FS_FILE_EXIST; } // create the file File::CreateFullPath(Filename); // just to be sure bool Result = File::CreateEmptyFile(Filename); if (!Result) { ERROR_LOG(WII_IPC_FILEIO, "CWII_IPC_HLE_Device_fs: couldn't create new file"); PanicAlert("CWII_IPC_HLE_Device_fs: couldn't create new file"); return FS_RESULT_FATAL; } INFO_LOG(WII_IPC_FILEIO, "\tresult = FS_RESULT_OK"); return FS_RESULT_OK; } break; case IOCTL_SHUTDOWN: { INFO_LOG(WII_IPC_FILEIO, "Wii called Shutdown()"); // TODO: stop emulation } break; default: ERROR_LOG(WII_IPC_FILEIO, "CWII_IPC_HLE_Device_fs::IOCtl: ni 0x%x", _Parameter); PanicAlert("CWII_IPC_HLE_Device_fs::IOCtl: ni 0x%x", _Parameter); break; } return FS_RESULT_FATAL; }
Bool DiffDistriDialog::Command(Int32 id, const BaseContainer &msg) { switch (id) { case IDC_DIFF_DISTRI_NEW_BTN: { Filename fn; if (fn.FileSelect(FILESELECTTYPE_ANYTHING, FILESELECT_LOAD, GeLoadString(IDS_DIFF_DISTRI_CHOOSE))) { if (!fn.CheckSuffix("zip")) { GeOutString(GeLoadString(IDS_DIFF_DISTRI_INVALID_SUFFIX), GEMB_OK | GEMB_ICONSTOP); } else { g_pResEditPrefs->arOldFiles.AddFilename(fn); m_pTreeView->Refresh(); } } } break; case IDC_DIFF_DISTRI_REMOVE_BTN: if (m_fnSelection.Content()) { g_pResEditPrefs->arOldFiles.RemoveFilename(m_fnSelection); m_fnSelection = Filename(); m_pTreeView->Refresh(); } break; case IDC_DIFF_DISTRI_NEWZIP_EDIT: g_pResEditPrefs->fnNewZip = m_pNewZipEdit->GetData().GetValue().GetFilename(); break; case IDC_DIFF_DISTRI_DESTPATH_EDIT: { Filename fnDestZip = m_pDestPathEdit->GetData().GetValue().GetFilename(); g_pResEditPrefs->fnDestZip = fnDestZip; g_pResEditPrefs->fnDestZip.SetSuffix("zip"); if (fnDestZip.Content() && g_pResEditPrefs->fnDestZip != fnDestZip) m_pDestPathEdit->SetData(TriState<GeData>(g_pResEditPrefs->fnDestZip)); } break; case IDC_OK: { GeData d; String strPassword; Int32 lLen = 0; char* pchPassword = nullptr; Filename fnDestZip = m_pDestPathEdit->GetData().GetValue().GetFilename(); g_pResEditPrefs->fnNewZip = m_pNewZipEdit->GetData().GetValue().GetFilename(); g_pResEditPrefs->fnDestZip = fnDestZip; g_pResEditPrefs->fnDestZip.SetSuffix("zip"); if (fnDestZip.Content() && g_pResEditPrefs->fnDestZip != fnDestZip) m_pDestPathEdit->SetData(TriState<GeData>(g_pResEditPrefs->fnDestZip)); GetString(IDC_DIFF_DISTRI_PASSWORD_EDIT, strPassword); lLen = strPassword.GetCStringLen(STRINGENCODING_8BIT); if (lLen) { pchPassword = NewMemClear(Char,lLen + 2); if (pchPassword) strPassword.GetCString(pchPassword, lLen + 1, STRINGENCODING_8BIT); } if (!g_pResEditPrefs->arOldFiles.GetElementCount()) { GeOutString(GeLoadString(IDS_DIFF_DISTRI_NO_OLD), GEMB_ICONSTOP); DeleteMem(pchPassword); break; } if (!g_pResEditPrefs->fnNewZip.Content()) { GeOutString(GeLoadString(IDS_DIFF_DISTRI_NO_NEW), GEMB_ICONSTOP); DeleteMem(pchPassword); break; } if (!g_pResEditPrefs->fnDestZip.Content()) { GeOutString(GeLoadString(IDS_DIFF_DISTRI_NO_DEST), GEMB_ICONSTOP); DeleteMem(pchPassword); break; } if (!DiffZipFiles(g_pResEditPrefs->arOldFiles, g_pResEditPrefs->fnNewZip, g_pResEditPrefs->fnDestZip, pchPassword)) GeOutString(GeLoadString(IDS_DIFF_DISTRI_FAILED, g_pResEditPrefs->fnNewZip.GetString(), g_pResEditPrefs->fnDestZip.GetString()), GEMB_OK | GEMB_ICONEXCLAMATION); DeleteMem(pchPassword); } break; case IDC_CANCEL: Close(); break; default: break; } return true; }
void HiJitCube::Init() throw (iException &) { // Get required keywords from instrument group Pvl *label(Label()); Isis::PvlGroup inst; Isis::PvlGroup idinst; jdata.filename = Filename(); Isis::PvlGroup &archive = label->FindGroup ("Archive",Isis::Pvl::Traverse); jdata.productId = (string) archive["ProductId"]; jdata.lines = Lines(); if (label->FindObject("IsisCube").HasGroup("OriginalInstrument")) { inst = label->FindGroup ("OriginalInstrument",Isis::Pvl::Traverse); originst = true; } else { inst = label->FindGroup ("Instrument",Isis::Pvl::Traverse); originst = false; } jdata.tdiMode = inst["Tdi"]; jdata.summing = inst["Summing"]; if (label->FindObject("IsisCube").HasGroup("Instrument") && originst) { idinst = label->FindGroup ("Instrument",Isis::Pvl::Traverse); jdata.pixpitch = idinst["PixelPitch"]; jdata.summing = (int) (jdata.pixpitch/.012); } if (originst && jdata.summing != 1 && !sampinit) { for (int i=0; i<14; i++) { npSamps[i] = (int) (npSamps[i]/(float)jdata.summing + 0.5); npSamp0[i] = (int) (npSamp0[i]/(float)jdata.summing + 0.5); } sampinit = true; } jdata.channelNumber = inst["ChannelNumber"]; jdata.cpmmNumber = inst["CpmmNumber"]; if (originst) { jdata.samples = npSamps[jdata.cpmmNumber]; } else { jdata.samples = Samples(); } jdata.ccdName = Instrument::CCD_NAMES[jdata.cpmmNumber]; jdata.dltCount = inst["DeltaLineTimerCount"]; jdata.UTCStartTime = (string) inst["StartTime"]; jdata.scStartTime = (string) inst["SpacecraftClockStartCount"]; try { if (originst) { jdata.fpSamp0 = npSamp0[jdata.cpmmNumber]; } else { jdata.fpSamp0 = Instrument::focal_plane_x_offset(jdata.cpmmNumber, jdata.summing); } } catch (Exception hiExc) { ostringstream msg; msg << "Summing mode (" << jdata.summing << ") is illegal (must be > 0) or CPMM number (" << jdata.cpmmNumber << ") is invalid in file " << Filename() << endl; throw iException::Message(iException::User,msg.str(),_FILEINFO_); } // It is assumed all images start at the line location in the focal plane jdata.fpLine0 = 0; // Validate channel number and adjust starting sample if ((jdata.channelNumber > 2) || (jdata.channelNumber < 0)) { ostringstream msg; msg << "Channel number (" << jdata.channelNumber << ") is invalid (must be 0, 1 or 2) in file " << Filename() << endl; throw iException::Message(iException::User,msg.str(),_FILEINFO_); } else { if (originst) { if (jdata.channelNumber == 0) jdata.fpSamp0 += npSamps[jdata.cpmmNumber]; } else { if (jdata.channelNumber == 0) jdata.fpSamp0 += Samples(); } } // Determine starting time of image and compute the binning rates computeStartTime(); // Compute the focal plane polygon for this image computePoly(); return; }
void main() { //vector<wstring> vFileNames = get_files_name(L"C:\\Users\\김송란\\Desktop\\송란이폴더\\랩세미나\\201603\\MunjaDB_IMG20160323\\*.bmp"); //vector<wstring> vFileNames = get_files_name(L"C:\\Users\\김송란\\Desktop\\송란이폴더\\랩세미나\\201603\\test\\*.bmp"); vector<wstring> vFileNames = get_files_name(L"C:\\Users\\김송란\\Documents\\GitHub\\MIPlab_seminar\\character recognition\\character recognition\\*.bmp"); //char *str; //sprintf(str, "%ls", vFileNames[0].c_str()); //wcout << vFileNames.size() << endl; //for (int i = 0; i < vFileNames.size(); i++) //{ // wcout << vFileNames[i] << endl; //} //int width, height; CHARACTER *Database_Char=(CHARACTER *)calloc(vFileNames.size(), sizeof(CHARACTER)); CHARACTER charname[50]; int a,b; string nameout; string test; vector<vector< string> > featureArr(600, vector<string>(600)); int file_count = vFileNames.size(); for (int i = 0; i < vFileNames.size(); i++) { test = CW2A(vFileNames[i].c_str());//wstring->string Mat A = imread(test, IMREAD_GRAYSCALE); // 파일명에서 알파벳 추출 a = test.find('['); b = test.find(']'); nameout = test.substr(a + 1, b-a-1); Database_Char[i].shape = nameout; Char_Feature(A,A.rows,A.cols, Database_Char[i]);//샘플특징 //int y = (int)(Database_Char[i].ratey * 100); //int x = (int)(Database_Char[i].ratex * 100); //featureArr[y][x] = Database_Char[i].shape; } Filename(file_count, Database_Char, charname); //중복되는 문자 하나로 Char_Feature_avg(charname, file_count, Database_Char);// 특징평균값 for (int i = 0; i < 50; i++) { cout << charname[i].shape<<" "<< charname[i].ratex << " " << charname[i].ratey <<" / "<< charname[i].avg1<< " / "<< charname[i].avg2<<" / "<< charname[i].avg3<<" / "<< charname[i].avg4<<endl; } int Optnum; CHARACTER input_Char; //string temp; //vector<wstring> inputfilenames = get_files_name(L"C:\\Users\\김송란\\Documents\\GitHub\\MIPlab_seminar\\character recognition\\character recognition\\*.bmp"); char dbname[200]; for (int i = 1; i <89; i++) { //sprintf(dbname, "C:\\Users\\김송란\\Documents\\카카오톡 받은 파일\\문자추출\\test%03d.bmp", i); sprintf(dbname, "C:\\Users\\김송란\\Documents\\카카오톡 받은 파일\\문자추출리사이즈\\resize%03d.bmp", i); Mat B = imread(dbname, IMREAD_GRAYSCALE); Char_Feature(B, B.rows, B.cols, input_Char); OptSample(charname, input_Char, &Optnum); cout << i << " 입력문자는 " << charname[Optnum].shape << "특징 - "<<charname[Optnum].avg1<< " / "<< charname[Optnum].avg2<<" / "<< charname[Optnum].avg3<<" / "<< charname[Optnum].avg4<<endl; } //CHARACTER input_Char; //Mat B = imread("C:\\Users\\김송란\\Documents\\GitHub\\MIPlab_seminar\\character recognition\\lineImg.bmp", IMREAD_GRAYSCALE); //입력 이미지 //Binary(B); ////imshow("input", B); ////waitKey(0); // ////라벨링 //Mat labelImage(B.rows, B.cols, CV_16UC1); //int label_count=connectedComponents(B, labelImage, 8); // 0까지 포함된 갯수임 ////imwrite("label.bmp", labelImage); // //int y_max[255] = { 0 }, x_max[255] = { 0 }; //int y_min[255], x_min[255]; //for (int i = 0; i < 255; i++) //{ // y_min[i] = B.rows; // x_min[i] = B.cols; //} // //Mat C(B.rows, B.cols, CV_8UC1); //for (int i = 0; i < B.rows; i++) // for (int j = 0; j < B.cols; j++) // { // C.at<unsigned char>(i, j) = B.at<unsigned char>(i, j); // } // //Find_MaxMin(labelImage, y_max, x_max, y_min, x_min); //MakingBox(labelImage, C,B, y_max, x_max, y_min, x_min, label_count); //imwrite("abc.bmp", C); //imshow("output", B); //waitKey(0); /* Char_Feature(B, B.rows, B.cols, input_Char); int y = (int)(input_Char.ratey * 100); int x = (int)(input_Char.ratex * 100); double err1, err2; double min_err1 = 100.0, min_err2 = 100.0; int c, d; for (int i = y - 10; i <= y + 10; i++) for (int j = x - 10; j <= x + 10; j++) { if (featureArr[i][j] != NULL) { err1 = abs(y - i); if (err1 < min_err1) { min_err1 = err1; err2 = abs(x - j); if (err2 < min_err2) { min_err2 = err2; c= i; d = j; } } } else cout << "없음" << endl; } cout << featureArr[c][d] << endl; */ //구조체 전달 확인 //opt_num=OptSample(Database_Char, input_Char,min_err,file_count); }
/*********************************************************************\ Function name : CResEditBrowser::Command Description : Created at : 25.09.01, @ 22:33:39 Created by : Thomas Kunert Modified by : \*********************************************************************/ Bool CResEditBrowser::Command(Int32 lID, const BaseContainer &msg) { switch (lID) { case IDC_BROWSE_BUTTON: { Filename fn = m_strPath; AutoAlloc <BrowseFiles> pFiles; pFiles->Init(Filename("\\"), false); if (!m_strPath.Content()) fn = GeGetStartupPath() + String("resource"); if (fn.FileSelect(FILESELECTTYPE_ANYTHING, FILESELECT_DIRECTORY, GeLoadString(IDS_SPECIFY_RES_PATH))) { m_strPath = fn; FillList(); } break; } case IDC_DIRECTORY_TREE: { TreeViewItem* pSelItem = (TreeViewItem*)msg.GetVoid(TREEVIEW_MESSAGE_ITEM); Int32 lType = msg.GetInt32(TREEVIEW_MESSAGE_TYPE); if (!pSelItem) break; if (lType == TREEVIEW_DOUBLECLICK) { Filename fn = pSelItem->GetData()->GetString(ITEM_PATH_NAME); if (fn.CheckSuffix("res")) { // open the resource file if (!g_bWasActive) { CResEditMenu m; m.Execute(nullptr); } if (!g_pTreeDialog) break; g_pTreeDialog->OpenDialog(fn); } else if (fn.CheckSuffix("str")) { CDialogDoc tempDoc; tempDoc.LoadGlobalStringTable(m_strPath, pSelItem->GetData()->GetString(TREEVIEW_TEXT)); CStringtableDialog dlg(&tempDoc, true); if (dlg.Open()) { if (GeOutString(GeLoadString(IDS_SAVE_STRINGTABLE), GEMB_YESNO | GEMB_ICONQUESTION) == GEMB_R_YES) { tempDoc.SaveGlobalStringTable(); } } } else if (fn.Content()) { // open the file (it may be an image) GeExecuteFile(fn); } return true; } else if (lType == TREEVIEW_SELCHANGE) { m_dirText = pSelItem->GetData()->GetString(ITEM_PATH_NAME); } break; } }; return GeDialog::Command(lID, msg); }
void FilenameTest::testIsValid() { QCOMPARE(Filename("").isValid(), false); QCOMPARE(Filename("%md5%").isValid(), false); QCOMPARE(Filename("toto").isValid(), false); QCOMPARE(Filename("%toto% %md5%.%ext%").isValid(), false); QCOMPARE(Filename("%md5%.%ext%").isValid(), true); QCOMPARE(Filename("%id%.%ext%").isValid(), false); QCOMPARE(Filename("%website%/%id%.%ext%").isValid(), true); QCOMPARE(Filename("%artist%/%copyright%/%character%/%md5%.%ext%").isValid(), true); QCOMPARE(Filename("javascript:md5 + '.' + ext;").isValid(), true); QCOMPARE(Filename("%md5% %date:format=yyyy-MM-dd%.%ext%").isValid(), true); QString out; Filename("%toto%.%ext%").isValid(&out); QCOMPARE(out.isEmpty(), false); }
int main() { std::cout << "###############################################" << std::endl; std::cout << "Running Shader AutoCompile...\n\n"; char aShaderDir[] = "Shader ASM\\*"; std::ofstream ShaderHeader("include\\Shader.h"); ShaderHeader << "// Auto generated shader opcodes\n\n"; WIN32_FIND_DATA FData; HANDLE hSearch = FindFirstFile(aShaderDir, &FData); do { if(FData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; // get ending std::string Filename(FData.cFileName); std::string Ending = Filename.substr(Filename.find_last_of('.')+1); std::string FileWithoutEnding = Filename.substr(0, Filename.find_last_of('.')); if(Ending == "psh" || Ending == "vsh") { bool PixelShader = Ending == "psh"; if(PixelShader) std::cout << "Found Pixelshader \"" << FData.cFileName << "\" .. compiling .." << std::endl; else std::cout << "Found Vertexshader \"" << FData.cFileName << "\" .. compiling .." << std::endl; ShaderHeader << "// " << Filename << ":" << std::endl; LPD3DXBUFFER pBuffer = nullptr; LPD3DXBUFFER pErrors = nullptr; D3DXAssembleShaderFromFile((std::string("Shader ASM\\") + FData.cFileName).c_str(), 0, 0, D3DXSHADER_OPTIMIZATION_LEVEL1, &pBuffer, &pErrors); if(pErrors == nullptr && pBuffer) { std::cout << "Succeded!" << std::endl; ShaderHeader << "const DWORD g_a" << FileWithoutEnding << (PixelShader ? "PS" : "VS") << "[] = { "; DWORD* pDWORDs = static_cast<DWORD*>(pBuffer->GetBufferPointer()); unsigned int NumTocken = pBuffer->GetBufferSize() / sizeof(DWORD); for(unsigned int i=0; i<NumTocken-1; ++i) ShaderHeader << pDWORDs[i] << ", "; ShaderHeader << pDWORDs[NumTocken-1] << " };\n\n"; } else { if(pErrors) std::cout << "Some errors occured:\n" << static_cast<char*>(pErrors->GetBufferPointer()) << std::endl << std::endl; else std::cout << "Some errors occured: - No description - \n\n"; } std::cout << std::endl; } } while(FindNextFile(hSearch,&FData)); ShaderHeader.close(); std::cout << "Shader AutoCompile finished!" << std::endl; std::cout << "###############################################\n\n"; }
BOOL ringFile::moveTo(LPCTSTR lpNewName,BOOL bForceOverWrite) { if(m_bExtern || lpNewName == NULL || *lpNewName == '\0') return FALSE; char dbuf[MAX_PATH]; DWORD attr = GetFileAttributes(lpNewName); if((attr & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY) { if(lpNewName[strlen(lpNewName)-1] == '\\') wsprintf(dbuf,"%s%s\0\0",lpNewName,Filename()); else wsprintf(dbuf,"%s\\%s\0\0",lpNewName,Filename()); } else strcpy(dbuf,lpNewName); DWORD how = bForceOverWrite?MOVEFILE_REPLACE_EXISTING:0; DWORD loc = 0UL; BOOL bOpened = (BOOL)m_hFile; // 如果文件处于打开状态,则先关闭它 if(m_hFile) { loc = GetRWLocation(); Close(); } // 移动文件 BOOL bOK; if(OSType() == OST_WINNT) bOK = ::MoveFileEx(m_szFilename,dbuf,how); else { bOK = copyTo(dbuf,how);//ringFile rf = dbuf; if(bOK) delIt(); } // 如果移动失败,恢复原状态 if(!bOK) { if(bOpened) { Open(RF_READWRITE); Seek(loc); } return FALSE; } // 关联到新的位置 SetFile(dbuf); if(bOpened) { Open(RF_READWRITE); Seek(loc); } return TRUE; }