// Save() // Save the file referenced within this class. Returns whatever // the GetLastError() function of the file format loader returned. // If a filename is provided, it will replace the filename already // existing in the instance. A new file format can also be passed in, // which will replace the existing file format. int ImageData::Save( const char * _filename, ImageFileFormats _file_format ) { // Check for a valid filename if( filename == NULL ) return IMGSAVER_INVALID_FILENAME; // Make sure there is an image to save if( image == NULL ) return IMGSAVER_INVALID_IMAGE; if( _file_format != IMGFF_UNKNOWN ) SetFileFormat( _file_format ); // Make sure the file format is valid if( (GetFileFormat() < 1) || (GetFileFormat() > IMGFF_NUM_FILE_FORMATS) ) { return IMGSAVER_INVALID_FILE_FORMAT; } // Auto-Add the extension and use the new filename, if applicable char new_filename[ MAX_PATH_LENGTH ]; if( _filename == NULL ) strcpy( new_filename, filename ); // Use the old name else strcpy( new_filename, _filename ); // Use the new name if( auto_extension ) { // Use the first extension, if applicable DirStrings::ChangeExtension( new_filename, GetExtensionList( _file_format )[0] ); SetFilename( new_filename ); } // Figure out which file format to save in // NOTE: If you add a new file format, you MUST insert the file // format's information here. This should consist of copying // one of the existing cases and replacing references to the // original file format to your new on. switch( file_format ) { case IMGFF_BMP: // BMP Image Saver BMP::Save( filename, this ); return BMP::GetLastError(); break; case IMGFF_TARGA: // Targa Image Saver // Targa::Save( file_name ); // return Targa::GetLastError(); break; case IMGFF_CSOURCE: // CSource Image Saver CSource::Save( filename, this ); return CSource::GetLastError(); break; // INSERT NEW FILE FORMAT HERE (SAVER) } // Unrecognized File Format; fail return IMGSAVER_UNRECOGNIZED_FILE_FORMAT; }
void CLDS2_UrlHandler_Base::FillInfo(SLDS2_File& info) { info.format = GetFileFormat(info); info.crc = GetFileCRC(info); info.size = GetFileSize(info); info.time = GetFileTime(info); }
spSongInfoT CPlayCenter::ParaseFromPath(CString sPath) { CSongInfo spSong; TStreamFormat tf = GetFileFormat(sPath); if (tf==TStreamFormat::sfUnknown) { // byte bb[128]={0}; // YTing::CMp3FileInfo::Mp3Info mp3 = YTing::CMp3FileInfo::getMp3Info(sPath,bb); } TID3InfoExW tid3; ZeroMemory(&tid3,sizeof(tid3)); spSong.SetLocalPath(sPath); spSong.SetLocal(true); spSong.SetAddTime(mci::now_time()); spSong.SetFileSize(mci::get_file_size(sPath)); spSong.SetFileStartPos(0); if(LoadFileInfo2(sPath,&tid3)) { spSong.SetArtistName((tid3.Artist)); spSong.SetSongName(tid3.Title); spSong.SetAblumName(tid3.Album); spSong.SetFileExt(mci::rip_file_ext(sPath,true)); spSong.SetRealArtistName(tid3.AlbumArtist); spSong.SetEnable(true); } spSongInfoT spSongInfo = spSongInfoT(new CSongInfo(spSong)); CheckSong(spSongInfo); return spSongInfo; }
bool OpenLangFile(api::File& LangFile, const string& Path,const string& Mask,const string& Language, string &strFileName, uintptr_t &nCodePage, bool StrongLang,string *pstrLangName) { strFileName.clear(); string strFullName, strEngFileName; api::FAR_FIND_DATA FindData; string strLangName; ScanTree ScTree(false, false); ScTree.SetFindPath(Path,Mask); while (ScTree.GetNextName(&FindData, strFullName)) { strFileName = strFullName; if (!LangFile.Open(strFileName, FILE_READ_DATA, FILE_SHARE_READ, nullptr, OPEN_EXISTING)) { strFileName.clear(); } else { GetFileFormat(LangFile, nCodePage, nullptr, false); if (GetLangParam(LangFile,L"Language",&strLangName,nullptr, nCodePage) && !StrCmpI(strLangName, Language)) break; LangFile.Close(); if (StrongLang) { strFileName.clear(); strEngFileName.clear(); break; } if (!StrCmpI(strLangName.data(),L"English")) strEngFileName = strFileName; } } if (!LangFile.Opened()) { if (!strEngFileName.empty()) strFileName = strEngFileName; if (!strFileName.empty()) { LangFile.Open(strFileName, FILE_READ_DATA, FILE_SHARE_READ, nullptr, OPEN_EXISTING); if (pstrLangName) *pstrLangName=L"English"; } } return LangFile.Opened(); }
Int_t KVRunListCreator::ScanDirectory() { // Return number of runs found KVSystemDirectory sysdir("rundir", GetRunDir()); TIter it(sysdir.GetListOfFiles()); KVSystemFile* sysfile; int howmany = 0; while ((sysfile = (KVSystemFile*)it())) { int run_num; if ((run_num = KVAvailableRunsFile::IsRunFileName(GetFileFormat(), sysfile->GetName()))) { KVDatime when; if (KVAvailableRunsFile::ExtractDateFromFileName(GetFileFormat(), sysfile->GetName(), when)) { ++howmany; KVNameValueList* infos = new KVNameValueList; infos->SetName(Form("run%06d", run_num)); infos->SetValue("Run", run_num); infos->SetValue("Start", when.AsSQLString()); infos->SetValue("End", sysfile->GetDate()); Int_t x = sysfile->GetSize(); if (x == sysfile->GetSize()) infos->SetValue("Size", x); else infos->SetValue64bit("Size", sysfile->GetSize()); if (fDataType != "") { fReader.reset(KVRawDataReader::OpenFile(fDataType, Form("%s/%s", sysdir.GetTitle(), sysfile->GetName()))); ULong64_t events = 0; while (fReader->GetNextEvent()) ++events; Int_t x = events; if (x == events) infos->SetValue("Events", x); else infos->SetValue64bit("Events", events); } infos->ls(); fRunInfos.Add(infos); } } } return howmany; }
////////////////////////////////////////////////////////////// // Description : Check which file type specified and call // appropriate loader. return new surface. ////////////////////////////////////////////////////////////// CDX_LPDIRECTDRAWSURFACE CDXImage::CreateDDSurface(CDX_LPDIRECTDRAW lpDD, LONG lSize, CHAR* lpCache, BYTE memType, DWORD type) { CDX_LPDIRECTDRAWSURFACE lpdds = NULL; // Determine the type if UNKNOWN if (type == CDXIMAGE_UNKNOWN) type = GetFileFormat(lSize, lpCache); switch (type) { case CDXIMAGE_UNKNOWN: OutputDebugString("Error: CDXImage - Unsupported Image type."); break; case CDXIMAGE_BMP: { CDXImageBMP gf; lpdds = gf.GetImage(lpDD, lSize, lpCache, memType); } break; case CDXIMAGE_TGA: { CDXImageTGA gf; lpdds = gf.GetImage(lpDD, lSize, lpCache, memType); } break; case CDXIMAGE_PSD: { CDXImagePSD gf; lpdds = gf.GetImage(lpDD, lSize, lpCache, memType); } break; case CDXIMAGE_PCX: { CDXImagePCX gf; lpdds = gf.GetImage(lpDD, lSize, lpCache, memType); } break; case CDXIMAGE_JPG: { CDXImageJPG gf; lpdds = gf.GetImage(lpDD, lSize, lpCache, memType); } break; //case CDXIMAGE_PNG: // { // CDXImagePNG gf; // lpdds = gf.GetImage(pSurface, lSize, lpCache, memType); // } // break; } return lpdds; }
//-------------------------------------------------------------- Image::Ptr ReadImage(const std::string& filename, FileFormat::Enum ff, PixelFormat::Enum pf) { File::Ptr file = OpenFile(filename); if (!file) { return 0; } if (ff == FileFormat::AutoDetect) { ff = GetFileFormat(filename); if (ff == FileFormat::Unknown) { ff = FileFormat::AutoDetect; } } return ReadImage(file, ff, pf); }
// -------------------------------------------------------- // // implementation of BFileInterface // -------------------------------------------------------- // status_t AbstractFileInterfaceNode::GetNextFileFormat( int32 * cookie, media_file_format * out_format) { CALLED(); // it's valid but they already got our 1 file format if (*cookie != 0) { PRINT("\t<- B_ERROR\n"); return B_ERROR; } // so next time they won't get the same format again *cookie = 1; GetFileFormat(out_format); return B_OK; }
//-------------------------------------------------------------- bool WriteImage(Image* image, const std::string& filename, FileFormat::Enum ff) { if (!image || filename.empty()) { return false; } File::Ptr file = OpenFile(filename, File::Out); if (!file) { return false; } if (ff == FileFormat::AutoDetect) { ff = GetFileFormat(filename); if (ff == FileFormat::Unknown) { return false; } } return WriteImage(image, file, ff); }
// OutputToStream() // Outputs an ImageData instance as ASCII text to the stream provided. void ImageData::OutputToStream( ostream &out ) { out << " Filename: \"" << GetFilename() << "\"" << endl; out << " File Format: " << GetFileFormat() << "; \"" << ImageFileFormatStrings[ GetFileFormat() ] << "\"" << endl; out << " File Size: " << GetFileSize() << " bytes " << endl; out << endl; out << " File Data:" << endl; out << " Bits Per Pixel: " << GetBitsPerPixel() << endl; out << " Compression: " << GetCompression() << "; \"" << ImageCompressionModeStrings[ GetCompression() ] << "\"" << endl; out << " DPI X/Y: " << GetDPIX() << "/" << GetDPIY() << endl; out << " Pixel Aspect Ration: " << GetPixelAspectNum() << "/" << GetPixelAspectDenom() << endl; out << " Gamma Correction: " << GetGammaNum() << "/" << GetGammaDenom() << endl; out << " Thumbnail: "; if( GetThumbnail() == NULL ) out << "No" << endl; else out << "Yes" << endl; out << endl; out << " Creator Data:" << endl; out << " Author: \"" << GetAuthor() << "\"" << endl; out << " Creator Program: \"" << GetCreator() << "\"" << endl; out << " Creator Version: " << GetCreatorVersion() << "." << GetCreatorRevision() << GetCreatorSubRev() << endl; out << " Comment: \"" << GetComment() << "\"" << endl; out << " Job Name: \"" << GetJobName() << "\"" << endl; out << " Job Time: " << GetJobTime()[0] << ":" << GetJobTime()[1] << ":" << GetJobTime()[2] << endl; out << " Date Stamp: " << GetDateStamp()[0] << "/" << GetDateStamp()[1] << "/" << GetDateStamp()[2] << " " << GetDateStamp()[3] << ":" << GetDateStamp()[4] << ":" << GetDateStamp()[5] << endl; out << endl; out << " Image Data:" << endl; out << " Width: " << GetImage()->GetWidth() << endl; out << " Height: " << GetImage()->GetHeight() << endl; out << " Type: " << GetImage()->GetType() << "; \"" << ImageTypeStrings[ GetImage()->GetType() ] << "\"" << endl; out << " Num Registers: "; if( GetImage()->GetType() == IMAGE_INDEXED ) out << GetImage()->GetNumRegisters() << endl; else out << "N/A" << endl; }
void MenuFileToList(DList<UserMenuItem> *Menu, File& MenuFile, GetFileString& GetStr, uintptr_t MenuCP = CP_UNICODE) { INT64 Pos = MenuFile.GetPointer(); if (!Pos) { if (!GetFileFormat(MenuFile,MenuCP)) MenuCP = CP_OEMCP; } LPWSTR MenuStr = nullptr; int MenuStrLength = 0; UserMenuItem *MenuItem = nullptr; while (GetStr.GetString(&MenuStr, MenuCP, MenuStrLength)) { RemoveTrailingSpaces(MenuStr); if (!*MenuStr) continue; if (*MenuStr==L'{' && MenuItem && MenuItem->Menu) { MenuFileToList(MenuItem->Menu, MenuFile, GetStr, MenuCP); MenuItem = nullptr; continue; } if (*MenuStr==L'}') break; if (!IsSpace(*MenuStr)) { wchar_t *ChPtr = nullptr; if (!(ChPtr=wcschr(MenuStr,L':'))) continue; MenuItem = Menu->Push(); *ChPtr = 0; MenuItem->strHotKey = MenuStr; MenuItem->strLabel = ChPtr+1; RemoveLeadingSpaces(MenuItem->strLabel); MenuItem->Submenu = (GetStr.PeekString(&MenuStr, MenuCP, MenuStrLength) && *MenuStr==L'{'); if (MenuItem->Submenu) MenuItem->Menu = new DList<UserMenuItem>(); // Support for old 1.x separator format if (MenuCP==CP_OEMCP && MenuItem->strHotKey==L"-" && MenuItem->strLabel.IsEmpty()) { MenuItem->strHotKey += L"-"; } } else if (MenuItem) { RemoveLeadingSpaces(MenuStr); string *str = MenuItem->Commands.Push(); *str = MenuStr; } } }
void DizList::Read(const string& Path, const string* DizName) { Reset(); TPreRedrawFuncGuard preRedrawFuncGuard(DizList::PR_ReadingMsg); const wchar_t *NamePtr=Opt.Diz.strListNames; for (;;) { if (DizName) { strDizFileName = *DizName; } else { strDizFileName = Path; if (!PathCanHoldRegularFile(strDizFileName)) break; string strArgName; if (!(NamePtr=GetCommaWord(NamePtr,strArgName))) break; AddEndSlash(strDizFileName); strDizFileName += strArgName; } File DizFile; if (DizFile.Open(strDizFileName,GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING)) { GetFileString GetStr(DizFile); wchar_t *DizText; int DizLength; clock_t StartTime=clock(); uintptr_t CodePage=CP_DEFAULT; bool bSigFound=false; if (!GetFileFormat(DizFile,CodePage,&bSigFound,false) || !bSigFound) CodePage = Opt.Diz.AnsiByDefault ? CP_ACP : CP_OEMCP; while (GetStr.GetString(&DizText, CodePage, DizLength) > 0) { if (!(DizCount & 127) && clock()-StartTime>1000) { SetCursorType(FALSE,0); PR_ReadingMsg(); if (CheckForEsc()) break; } RemoveTrailingSpaces(DizText); if (*DizText) AddRecord(DizText); } OrigCodePage=CodePage; Modified=false; DizFile.Close(); return; } if (DizName) break; } Modified=false; strDizFileName.Clear(); }
void SupplyData::CreateOvernetPacket() { int tag_count=0; PacketBuffer next_buf; //filename next_buf.PutByte(0x02); next_buf.PutUShort(1); next_buf.PutByte(0x01); next_buf.PutUShort(m_filename.length()); next_buf.PutStr(m_filename.c_str(),m_filename.length()); tag_count++; //filesize //make a divisable to 137 UINT new_filesize = m_filesize - (m_filesize%137); next_buf.PutByte(0x03); next_buf.PutUShort(1); next_buf.PutByte(0x02); next_buf.PutUInt(new_filesize); tag_count++; //file type audio if(stricmp(m_file_type.c_str(),"audio")==0) { next_buf.PutByte(0x02); next_buf.PutUShort(1); next_buf.PutByte(0x03); next_buf.PutUShort(5); // "Audio" length next_buf.PutStr("Audio",5); tag_count++; //Artist if(m_artist.length()>0) { next_buf.PutByte(0x02); next_buf.PutUShort(6); next_buf.PutStr("Artist",6); next_buf.PutUShort(m_artist.length()); next_buf.PutStr(m_artist.c_str(),m_artist.length()); tag_count++; } //Album if(m_album.length()>0) { next_buf.PutByte(0x02); next_buf.PutUShort(5); next_buf.PutStr("Album",5); next_buf.PutUShort(m_album.length()); next_buf.PutStr(m_album.c_str(),m_album.length()); tag_count++; } //Title if(m_title.length()>0) { next_buf.PutByte(0x02); next_buf.PutUShort(5); next_buf.PutStr("Title",5); next_buf.PutUShort(m_title.length()); next_buf.PutStr(m_title.c_str(),m_title.length()); tag_count++; } //bitrate if(m_bitrate!=0) { next_buf.PutByte(0x03); next_buf.PutUShort(7); next_buf.PutStr("bitrate",7); next_buf.PutUInt(m_bitrate); tag_count++; } //file format CString format=GetFileFormat(m_filename.c_str()); if(format.GetLength()>0) { next_buf.PutByte(0x02); next_buf.PutUShort(1); next_buf.PutByte(0x04); next_buf.PutUShort(format.GetLength()); next_buf.PutStr(format,format.GetLength()); tag_count++; } //Length if(m_media_len>0) { CString str_length; if( m_media_len >= 3600) str_length.Format("%.dh %.dm %.ds", (int)((float)m_media_len/3600), (int)((m_media_len%3600)/60), (int)((m_media_len%3600)%60)); else str_length.Format("%.2d:%.2d",(int)((float)m_media_len/60), (int)(m_media_len%60)); next_buf.PutByte(0x02); next_buf.PutUShort(6); next_buf.PutStr("length",6); next_buf.PutUShort(str_length.GetLength()); next_buf.PutStr(str_length,str_length.GetLength()); tag_count++; } } else if(stricmp(m_file_type.c_str(),"video")==0) { next_buf.PutByte(0x02); next_buf.PutUShort(1); next_buf.PutByte(0x03); next_buf.PutUShort(5); // "Video" length next_buf.PutStr("Video",5); tag_count++; //Codec if(m_codec.length()>0) { next_buf.PutByte(0x02); next_buf.PutUShort(5); next_buf.PutStr("codec",5); next_buf.PutUShort(m_codec.length()); next_buf.PutStr(m_codec.c_str(),m_codec.length()); tag_count++; } //Length if(m_media_len>0) { CString str_length; if( m_media_len >= 3600) str_length.Format("%.dh %.dm %.ds", (int)((float)m_media_len/3600), (int)((m_media_len%3600)/60), (int)((m_media_len%3600)%60)); else str_length.Format("%.2d:%.2d",(int)((float)m_media_len/60), (int)(m_media_len%60)); next_buf.PutByte(0x02); next_buf.PutUShort(6); next_buf.PutStr("length",6); next_buf.PutUShort(str_length.GetLength()); next_buf.PutStr(str_length,str_length.GetLength()); tag_count++; } //file format CString format=GetFileFormat(m_filename.c_str()); if(format.GetLength()>0) { next_buf.PutByte(0x02); next_buf.PutUShort(1); next_buf.PutByte(0x04); next_buf.PutUShort(format.GetLength()); next_buf.PutStr(format,format.GetLength()); tag_count++; } } else if( stricmp(m_file_type.c_str(),"software")==0) { next_buf.PutByte(0x02); next_buf.PutUShort(1); next_buf.PutByte(0x03); next_buf.PutUShort(3); // "Pro" length next_buf.PutStr("Pro",3); tag_count++; } //Avaiability next_buf.PutByte(0x03); next_buf.PutUShort(1); next_buf.PutByte(0x15); int rand1 = rand()%3; //randomly pick an availability number switch (rand1) { case 0: // one third will be either 254 or 255 { if( (rand()%2)==0 ) next_buf.PutUInt(255); else next_buf.PutUInt(254); break; } case 1: case 2: //two third will be 245 - 253 { int rand2 = rand()%9; switch (rand2) { case 0: { next_buf.PutUInt(253); break; } case 1: { next_buf.PutUInt(252); break; } case 2: { next_buf.PutUInt(251); break; } case 3: { next_buf.PutUInt(250); break; } case 4: { next_buf.PutUInt(249); break; } case 5: { next_buf.PutUInt(248); break; } case 6: { next_buf.PutUInt(247); break; } case 7: { next_buf.PutUInt(246); break; } case 8: { next_buf.PutUInt(245); break; } } break; } } tag_count++; if(p_overnet_supply_packet!=NULL) delete p_overnet_supply_packet; p_overnet_supply_packet = new PacketBuffer(); p_overnet_supply_packet->PutUInt(tag_count); //meta tag list size p_overnet_supply_packet->Append(next_buf); }
static bool SelectLanguage(bool HelpLanguage) { const wchar_t *Title,*Mask; StringOption *strDest; if (HelpLanguage) { Title=MSG(MHelpLangTitle); Mask=Global->HelpFileMask; strDest=&Global->Opt->strHelpLanguage; } else { Title=MSG(MLangTitle); Mask=LangFileMask; strDest=&Global->Opt->strLanguage; } VMenu2 LangMenu(Title,nullptr,0,ScrY-4); LangMenu.SetFlags(VMENU_WRAPMODE); LangMenu.SetPosition(ScrX/2-8+5*HelpLanguage,ScrY/2-4+2*HelpLanguage,0,0); string strFullName; api::FAR_FIND_DATA FindData; ScanTree ScTree(false, false); ScTree.SetFindPath(Global->g_strFarPath, Mask); while (ScTree.GetNextName(&FindData,strFullName)) { api::File LangFile; if (!LangFile.Open(strFullName, FILE_READ_DATA, FILE_SHARE_READ, nullptr, OPEN_EXISTING)) continue; uintptr_t nCodePage=CP_OEMCP; GetFileFormat(LangFile, nCodePage, nullptr, false); string strLangName, strLangDescr; if (GetLangParam(LangFile,L"Language",&strLangName,&strLangDescr,nCodePage)) { string strEntryName; if (!HelpLanguage || (!GetLangParam(LangFile,L"PluginContents",&strEntryName,nullptr,nCodePage) && !GetLangParam(LangFile,L"DocumentContents",&strEntryName,nullptr,nCodePage))) { MenuItemEx LangMenuItem(str_printf(L"%.40s", !strLangDescr.empty() ? strLangDescr.data():strLangName.data())); /* $ 01.08.2001 SVS Не допускаем дубликатов! Если в каталог с ФАРом положить еще один HLF с одноименным языком, то... фигня получается при выборе языка. */ if (LangMenu.FindItem(0,LangMenuItem.strName,LIFIND_EXACTMATCH) == -1) { LangMenuItem.SetSelect(!StrCmpI(*strDest, strLangName)); LangMenu.SetUserData(strLangName.data(), (strLangName.size()+1)*sizeof(wchar_t), LangMenu.AddItem(LangMenuItem)); } } } } LangMenu.AssignHighlights(FALSE); LangMenu.Run(); if (LangMenu.GetExitCode()<0) return false; *strDest = static_cast<const wchar_t*>(LangMenu.GetUserData(nullptr, 0)); return true; }
void DizList::Read(const string& Path, const string* DizName) { Reset(); struct DizPreRedrawItem : public PreRedrawItem { DizPreRedrawItem() : PreRedrawItem(PR_ReadingMsg) {} }; SCOPED_ACTION(TPreRedrawFuncGuard)(std::make_unique<DizPreRedrawItem>()); const wchar_t *NamePtr=Global->Opt->Diz.strListNames.data(); for (;;) { if (DizName) { strDizFileName = *DizName; } else { strDizFileName = Path; if (!PathCanHoldRegularFile(strDizFileName)) break; string strArgName; NamePtr = GetCommaWord(NamePtr, strArgName); if (!NamePtr) break; AddEndSlash(strDizFileName); strDizFileName += strArgName; } os::fs::file DizFile; if (DizFile.Open(strDizFileName,GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING)) { clock_t StartTime=clock(); uintptr_t CodePage=CP_DEFAULT; bool bSigFound=false; if (!GetFileFormat(DizFile,CodePage,&bSigFound,false) || !bSigFound) CodePage = Global->Opt->Diz.AnsiByDefault ? CP_ACP : CP_OEMCP; GetFileString GetStr(DizFile, CodePage); auto LastAdded = DizData.end(); string DizText; while (GetStr.GetString(DizText)) { if (!(DizData.size() & 127) && clock() - StartTime > CLOCKS_PER_SEC) { SetCursorType(false, 0); PR_ReadingMsg(); if (CheckForEsc()) break; } RemoveTrailingSpaces(DizText); if (!DizText.empty()) { if(!IsSpace(DizText.front())) { LastAdded = AddRecord(DizText); } else { if (LastAdded != DizData.end()) { LastAdded->second.emplace_back(DizText); } } } } OrigCodePage=CodePage; Modified=false; DizFile.Close(); return; } if (DizName) break; } Modified=false; strDizFileName.clear(); }
bool FOneSkyUploadFileWorker::Execute(class FOneSkyLocalizationServiceCommand& InCommand) { // Store pointer to command so we can access it in the http request callback Command = &InCommand; TSharedPtr<FUploadLocalizationTargetFile, ESPMode::ThreadSafe> UploadFileOp = StaticCastSharedRef<FUploadLocalizationTargetFile>(InCommand.Operation); FGuid InTargetGuid; FString InFilePathAndName = ""; FString InLocale = ""; bool bInIsKeepingAllStrings = true; FString InFileFormat = ""; if (UploadFileOp.IsValid()) { InTargetGuid = UploadFileOp->GetInTargetGuid(); InLocale = UploadFileOp->GetInLocale(); // Path is relative to game directory InFilePathAndName = FPaths::ConvertRelativePathToFull(FPaths::GameDir() / UploadFileOp->GetInRelativeInputFilePathAndName()); bInIsKeepingAllStrings = UploadFileOp->GetPreserveAllText(); InFileFormat = GetFileFormat(FPaths::GetExtension(InFilePathAndName, true)); } int32 InProjectId = -1; FString InOneSkyTargetFileName = ""; // OneSky project settings are accessed by their localization target guid. These settings are set in the Localization Dashboard FOneSkyLocalizationTargetSetting* Settings = FOneSkyLocalizationServiceModule::Get().AccessSettings().GetSettingsForTarget(InTargetGuid); if (Settings != nullptr) { InProjectId = Settings->OneSkyProjectId; InOneSkyTargetFileName = FPlatformHttp::UrlEncode(Settings->OneSkyFileName); } FString Url = AddAuthenticationParameters(InCommand.ConnectionInfo, "https://platform.api.onesky.io/1/projects/" + FString::FromInt(InProjectId) / "files"); Url += "&file_format=" + InFileFormat + "&locale=" + InLocale; if (!bInIsKeepingAllStrings) { Url += "&is_keeping_all_strings=false"; } FHttpModule& HttpModule = FModuleManager::LoadModuleChecked<FHttpModule>("HTTP"); TSharedRef<class IHttpRequest> HttpRequest = HttpModule.Get().CreateRequest(); // kick off http request to read HttpRequest->OnProcessRequestComplete().BindRaw(this, &FOneSkyUploadFileWorker::Query_HttpRequestComplete); HttpRequest->SetURL(Url); FString Boundary = "---------------------------" + FString::FromInt(FDateTime::Now().GetTicks()); HttpRequest->SetHeader(TEXT("Content-Type"), TEXT("multipart/form-data; boundary =" + Boundary)); HttpRequest->SetVerb(TEXT("POST")); FString FileContents; if (FFileHelper::LoadFileToString(FileContents, *InFilePathAndName, FFileHelper::EEncodingOptions::ForceUnicode)) { // Format the file the way OneSky wants it (in a form, with the file contents being a field called "file") FString PrefixBoundry = "\r\n--" + Boundary + "\r\n"; FString FileHeader = "Content-Disposition: form-data; name=\"file\"; filename=\"" + InOneSkyTargetFileName + "\"\r\nContent-Type: " + InFileFormat + "\r\n\r\n"; FString SuffixBoundary = "\r\n--" + Boundary + "--\r\n"; FString ContentsString = PrefixBoundry + FileHeader + FileContents + SuffixBoundary; HttpRequest->SetContentAsString(ContentsString); HttpRequest->ProcessRequest(); } else { Command->bCommandSuccessful = false; FPlatformAtomics::InterlockedExchange(&(Command->bExecuteProcessed), 1); } return InCommand.bCommandSuccessful; }