// Loads the file as a new OpenCL program, builds it on the device, and then // creates an OpenCL kernel with the result. cl::Kernel OpenclImageProcessor::LoadKernel(string filename, string kernel_name, bool use_gpu) { ifstream cl_file(KernelPath(filename, use_gpu)); if (!cl_file.good()) cerr << "Couldn't open " << KernelPath(filename, use_gpu) << endl; // Read the kernel file and create a cl::Program with it. string cl_string(istreambuf_iterator<char>(cl_file), (istreambuf_iterator<char>())); cl::Program::Sources source( 1, make_pair(cl_string.c_str(), cl_string.length() + 1)); cl::Program program(context_, source); try { program.build(devices_); } catch (cl::Error e) { // If there's a build error, print out the build log to see what // exactly the problem was. cerr << "Build Status:\t" << program.getBuildInfo<CL_PROGRAM_BUILD_STATUS>(selected_device_) << endl << "Build Options:\t" << program.getBuildInfo<CL_PROGRAM_BUILD_OPTIONS>(selected_device_) << endl << "Build Log:\t " << program.getBuildInfo<CL_PROGRAM_BUILD_LOG>(selected_device_) << endl; } return cl::Kernel(program, kernel_name.c_str()); }
bool ModifyReparsePoint(const string& Object,const string& NewData) { block_ptr<REPARSE_DATA_BUFFER> rdb(MAXIMUM_REPARSE_DATA_BUFFER_SIZE); if (!GetREPARSE_DATA_BUFFER(Object, rdb.get())) return false; switch (rdb->ReparseTag) { case IO_REPARSE_TAG_MOUNT_POINT: { const auto strPrintName = ConvertNameToFull(NewData); const auto strSubstituteName = KernelPath(NTPath(strPrintName)); if (!FillREPARSE_DATA_BUFFER(rdb.get(), strPrintName, strSubstituteName)) { SetLastError(ERROR_INSUFFICIENT_BUFFER); return false; } } break; case IO_REPARSE_TAG_SYMLINK: { const auto& strPrintName = NewData; auto strSubstituteName = NewData; if (IsAbsolutePath(NewData)) { strSubstituteName = KernelPath(NTPath(strSubstituteName)); rdb->SymbolicLinkReparseBuffer.Flags=0; } else { rdb->SymbolicLinkReparseBuffer.Flags=SYMLINK_FLAG_RELATIVE; } if (!FillREPARSE_DATA_BUFFER(rdb.get(), strPrintName, strSubstituteName)) { SetLastError(ERROR_INSUFFICIENT_BUFFER); return false; } } break; default: return false; } return SetREPARSE_DATA_BUFFER(Object,rdb.get()); }
bool CreateReparsePoint(const string& Target, const string& Object,ReparsePointTypes Type) { bool Result=false; { switch (Type) { case RP_HARDLINK: break; case RP_EXACTCOPY: Result=DuplicateReparsePoint(Target,Object); break; case RP_SYMLINK: case RP_SYMLINKFILE: case RP_SYMLINKDIR: { os::fs::file_status ObjectStatus(Object); if(Type == RP_SYMLINK) { Type = os::fs::is_directory(Target)? RP_SYMLINKDIR : RP_SYMLINKFILE; } if (imports.CreateSymbolicLinkW && !os::fs::exists(ObjectStatus)) { Result=os::fs::CreateSymbolicLink(Object,Target,Type==RP_SYMLINKDIR?SYMBOLIC_LINK_FLAG_DIRECTORY:0); } else { const auto ObjectCreated = Type==RP_SYMLINKDIR? os::fs::is_directory(ObjectStatus) || os::fs::create_directory(Object) : os::fs::is_file(ObjectStatus) || os::fs::file(Object, 0, 0, nullptr, CREATE_NEW); if (ObjectCreated) { block_ptr<REPARSE_DATA_BUFFER> rdb(MAXIMUM_REPARSE_DATA_BUFFER_SIZE); rdb->ReparseTag=IO_REPARSE_TAG_SYMLINK; const auto& strPrintName = Target; auto strSubstituteName = Target; if (IsAbsolutePath(Target)) { strSubstituteName = KernelPath(NTPath(strSubstituteName)); rdb->SymbolicLinkReparseBuffer.Flags=0; } else { rdb->SymbolicLinkReparseBuffer.Flags=SYMLINK_FLAG_RELATIVE; } if (FillREPARSE_DATA_BUFFER(rdb.get(), strPrintName, strSubstituteName)) { Result=SetREPARSE_DATA_BUFFER(Object,rdb.get()); } else { SetLastError(ERROR_INSUFFICIENT_BUFFER); } } } } break; case RP_JUNCTION: case RP_VOLMOUNT: { const auto strPrintName = ConvertNameToFull(Target); auto strSubstituteName = KernelPath(NTPath(strPrintName)); block_ptr<REPARSE_DATA_BUFFER> rdb(MAXIMUM_REPARSE_DATA_BUFFER_SIZE); rdb->ReparseTag=IO_REPARSE_TAG_MOUNT_POINT; if (FillREPARSE_DATA_BUFFER(rdb.get(), strPrintName, strSubstituteName)) { Result=SetREPARSE_DATA_BUFFER(Object,rdb.get()); } else { SetLastError(ERROR_INSUFFICIENT_BUFFER); } } break; } } return Result; }