• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ OrthancException函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中OrthancException函数的典型用法代码示例。如果您正苦于以下问题:C++ OrthancException函数的具体用法?C++ OrthancException怎么用?C++ OrthancException使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了OrthancException函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: OrthancException

  void HttpClient::Setup()
  {
    pimpl_->postHeaders_ = NULL;
    if ((pimpl_->postHeaders_ = curl_slist_append(pimpl_->postHeaders_, "Expect:")) == NULL)
    {
      throw OrthancException(ErrorCode_NotEnoughMemory);
    }

    pimpl_->curl_ = curl_easy_init();
    if (!pimpl_->curl_)
    {
      curl_slist_free_all(pimpl_->postHeaders_);
      throw OrthancException(ErrorCode_NotEnoughMemory);
    }

    CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_WRITEFUNCTION, &CurlCallback));
    CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_HEADER, 0));
    CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_FOLLOWLOCATION, 1));

#if ORTHANC_SSL_ENABLED == 1
    CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_SSL_VERIFYPEER, 0)); 
#endif

    // This fixes the "longjmp causes uninitialized stack frame" crash
    // that happens on modern Linux versions.
    // http://stackoverflow.com/questions/9191668/error-longjmp-causes-uninitialized-stack-frame
    CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_NOSIGNAL, 1));

    url_ = "";
    method_ = HttpMethod_Get;
    lastStatus_ = HttpStatus_200_Ok;
    isVerbose_ = false;
    timeout_ = 0;
  }
开发者ID:gbanana,项目名称:orthanc,代码行数:34,代码来源:HttpClient.cpp


示例2: PngRabi

    PngRabi()
    {
      png_ = NULL;
      info_ = NULL;
      endInfo_ = NULL;

      png_ = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
      if (!png_)
      {
        throw OrthancException(ErrorCode_NotEnoughMemory);
      }

      info_ = png_create_info_struct(png_);
      if (!info_)
      {
        png_destroy_read_struct(&png_, NULL, NULL);
        throw OrthancException(ErrorCode_NotEnoughMemory);
      }

      endInfo_ = png_create_info_struct(png_);
      if (!info_)
      {
        png_destroy_read_struct(&png_, &info_, NULL);
        throw OrthancException(ErrorCode_NotEnoughMemory);
      }
    }
开发者ID:PACSinTERRA,项目名称:orthanc,代码行数:26,代码来源:PngReader.cpp


示例3: path_

  SharedLibrary::SharedLibrary(const std::string& path) : 
    path_(path), 
    handle_(NULL)
  {
#if defined(_WIN32)
    handle_ = ::LoadLibraryA(path_.c_str());
    if (handle_ == NULL)
    {
      LOG(ERROR) << "LoadLibrary(" << path_ << ") failed: Error " << ::GetLastError();
      throw OrthancException(ErrorCode_SharedLibrary);
    }

#elif defined(__linux__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD_kernel__) || defined(__FreeBSD__)
    handle_ = ::dlopen(path_.c_str(), RTLD_NOW);
    if (handle_ == NULL) 
    {
      std::string explanation;
      const char *tmp = ::dlerror();
      if (tmp)
      {
        explanation = ": Error " + std::string(tmp);
      }

      LOG(ERROR) << "dlopen(" << path_ << ") failed" << explanation;
      throw OrthancException(ErrorCode_SharedLibrary);
    }

#else
#error Support your platform here
#endif   
  }
开发者ID:PACSinTERRA,项目名称:orthanc,代码行数:31,代码来源:SharedLibrary.cpp


示例4: switch

  void HttpOutput::StateMachine::CloseBody()
  {
    switch (state_)
    {
      case State_WritingHeader:
        SetContentLength(0);
        SendBody(NULL, 0);
        break;

      case State_WritingBody:
        if (!hasContentLength_ ||
            contentPosition_ == contentLength_)
        {
          state_ = State_Done;
        }
        else
        {
          LOG(ERROR) << "The body size has not reached what was declared with SetContentSize()";
          throw OrthancException(ErrorCode_BadSequenceOfCalls);
        }

        break;

      case State_WritingMultipart:
        LOG(ERROR) << "Cannot invoke CloseBody() with multipart outputs";
        throw OrthancException(ErrorCode_BadSequenceOfCalls);

      case State_Done:
        return;  // Ignore

      default:
        throw OrthancException(ErrorCode_InternalError);
    }      
  }
开发者ID:ming-hai,项目名称:orthanc,代码行数:34,代码来源:HttpOutput.cpp


示例5: OrthancException

 StatementReference::~StatementReference()
 {
   if (IsRoot())
   {
     if (refCount_ != 0)
     {
       // There remain references to this object
       throw OrthancException(ErrorCode_InternalError);
     }
     else if (statement_ != NULL)
     {
       sqlite3_finalize(statement_);
     }
   }
   else
   {
     if (root_->refCount_ == 0)
     {
       throw OrthancException(ErrorCode_InternalError);
     }
     else
     {
       root_->refCount_--;
     }
   }
 }
开发者ID:amirkogithub,项目名称:orthanc,代码行数:26,代码来源:StatementReference.cpp


示例6: OrthancException

  void PngReader::ReadFromMemory(const void* buffer,
                                 size_t size)
  {
    if (size < 8)
    {
      throw OrthancException(ErrorCode_BadFileFormat);
    }

    CheckHeader(buffer);

    PngRabi rabi;

    if (setjmp(png_jmpbuf(rabi.png_)))
    {
      rabi.Destruct();
      throw OrthancException(ErrorCode_BadFileFormat);
    }

    MemoryBuffer tmp;
    tmp.buffer_ = reinterpret_cast<const uint8_t*>(buffer) + 8;  // We skip the header
    tmp.size_ = size - 8;
    tmp.pos_ = 0;
    tmp.ok_ = true;

    png_set_read_fn(rabi.png_, &tmp, PngRabi::MemoryCallback);

    Read(rabi);

    if (!tmp.ok_)
    {
      throw OrthancException(ErrorCode_BadFileFormat);
    }
  }
开发者ID:PACSinTERRA,项目名称:orthanc,代码行数:33,代码来源:PngReader.cpp


示例7: Prepare

  void PngWriter::WriteToFile(const char* filename,
                              unsigned int width,
                              unsigned int height,
                              unsigned int pitch,
                              PixelFormat format,
                              const void* buffer)
  {
    Prepare(width, height, pitch, format, buffer);

    FILE* fp = fopen(filename, "wb");
    if (!fp)
    {
      throw OrthancException(ErrorCode_CannotWriteFile);
    }    

    png_init_io(pimpl_->png_, fp);

    if (setjmp(png_jmpbuf(pimpl_->png_)))
    {
      // Error during writing PNG
      throw OrthancException(ErrorCode_CannotWriteFile);      
    }

    Compress(width, height, pitch, format);

    fclose(fp);
  }
开发者ID:dhanzhang,项目名称:orthanc,代码行数:27,代码来源:PngWriter.cpp


示例8: OrthancException

  void DicomServer::SetApplicationEntityTitle(const std::string& aet)
  {
    if (aet.size() == 0)
    {
      throw OrthancException(ErrorCode_BadApplicationEntityTitle);
    }

    if (aet.size() > 16)
    {
      throw OrthancException(ErrorCode_BadApplicationEntityTitle);
    }

    for (size_t i = 0; i < aet.size(); i++)
    {
      if (!(aet[i] == '-' ||
            aet[i] == '_' ||
            isdigit(aet[i]) ||
            (aet[i] >= 'A' && aet[i] <= 'Z')))
      {
        LOG(WARNING) << "For best interoperability, only upper case, alphanumeric characters should be present in AET: \"" << aet << "\"";
        break;
      }
    }

    Stop();
    aet_ = aet;
  }
开发者ID:ming-hai,项目名称:orthanc,代码行数:27,代码来源:DicomServer.cpp


示例9: Prepare

  void PngWriter::WriteToFileInternal(const std::string& filename,
                                      unsigned int width,
                                      unsigned int height,
                                      unsigned int pitch,
                                      PixelFormat format,
                                      const void* buffer)
  {
    Prepare(width, height, pitch, format, buffer);

    FILE* fp = Toolbox::OpenFile(filename, FileMode_WriteBinary);
    if (!fp)
    {
      throw OrthancException(ErrorCode_CannotWriteFile);
    }    

    png_init_io(pimpl_->png_, fp);

    if (setjmp(png_jmpbuf(pimpl_->png_)))
    {
      // Error during writing PNG
      throw OrthancException(ErrorCode_CannotWriteFile);      
    }

    Compress(width, height, pitch, format);

    fclose(fp);
  }
开发者ID:151706061,项目名称:OrthancMirror,代码行数:27,代码来源:PngWriter.cpp


示例10: OrthancException

  void ZipWriter::Open()
  {
    if (IsOpen())
    {
      return;
    }

    if (path_.size() == 0)
    {
      throw OrthancException("Please call SetOutputPath() before creating the file");
    }

    hasFileInZip_ = false;

    if (isZip64_)
    {
      pimpl_->file_ = zipOpen64(path_.c_str(), APPEND_STATUS_CREATE);
    }
    else
    {
      pimpl_->file_ = zipOpen(path_.c_str(), APPEND_STATUS_CREATE);
    }

    if (!pimpl_->file_)
    {
      throw OrthancException(ErrorCode_CannotWriteFile);
    }
  }
开发者ID:freemed,项目名称:orthanc,代码行数:28,代码来源:ZipWriter.cpp


示例11: ParseListOfTags

  static void ParseListOfTags(DicomModification& target,
                              const Json::Value& query,
                              TagOperation operation)
  {
    if (!query.isArray())
    {
      throw OrthancException(ErrorCode_BadRequest);
    }

    for (Json::Value::ArrayIndex i = 0; i < query.size(); i++)
    {
      std::string name = query[i].asString();

      DicomTag tag = FromDcmtkBridge::ParseTag(name);

      switch (operation)
      {
        case TagOperation_Keep:
          target.Keep(tag);
          VLOG(1) << "Keep: " << name << " " << tag << std::endl;
          break;

        case TagOperation_Remove:
          target.Remove(tag);
          VLOG(1) << "Remove: " << name << " " << tag << std::endl;
          break;

        default:
          throw OrthancException(ErrorCode_InternalError);
      }
    }
  }
开发者ID:dhanzhang,项目名称:orthanc,代码行数:32,代码来源:OrthancRestAnonymizeModify.cpp


示例12: compressBound

  void ZlibCompressor::Compress(std::string& compressed,
                                const void* uncompressed,
                                size_t uncompressedSize)
  {
    if (uncompressedSize == 0)
    {
      compressed.clear();
      return;
    }

    uLongf compressedSize = compressBound(uncompressedSize) + 1024 /* security margin */;
    if (compressedSize == 0)
    {
      compressedSize = 1;
    }

    uint8_t* target;
    if (HasPrefixWithUncompressedSize())
    {
      compressed.resize(compressedSize + sizeof(uint64_t));
      target = reinterpret_cast<uint8_t*>(&compressed[0]) + sizeof(uint64_t);
    }
    else
    {
      compressed.resize(compressedSize);
      target = reinterpret_cast<uint8_t*>(&compressed[0]);
    }

    int error = compress2(target,
                          &compressedSize,
                          const_cast<Bytef *>(static_cast<const Bytef *>(uncompressed)), 
                          uncompressedSize,
                          GetCompressionLevel());

    if (error != Z_OK)
    {
      compressed.clear();

      switch (error)
      {
      case Z_MEM_ERROR:
        throw OrthancException(ErrorCode_NotEnoughMemory);

      default:
        throw OrthancException(ErrorCode_InternalError);
      }  
    }

    // The compression was successful
    if (HasPrefixWithUncompressedSize())
    {
      uint64_t s = static_cast<uint64_t>(uncompressedSize);
      memcpy(&compressed[0], &s, sizeof(uint64_t));
      compressed.resize(compressedSize + sizeof(uint64_t));
    }
    else
    {
      compressed.resize(compressedSize);
    }
  }
开发者ID:milhcbt,项目名称:OrthancMirror,代码行数:60,代码来源:ZlibCompressor.cpp


示例13: OrthancException

  void DicomInstanceToStore::ComputeMissingInformation()
  {
    if (buffer_.HasContent() &&
        summary_.HasContent() &&
        json_.HasContent())
    {
      // Fine, everything is available
      return; 
    }
    
    if (!buffer_.HasContent())
    {
      if (!parsed_.HasContent())
      {
        throw OrthancException(ErrorCode_NotImplemented);
      }
      else
      {
        // Serialize the parsed DICOM file
        buffer_.Allocate();
        if (!FromDcmtkBridge::SaveToMemoryBuffer(buffer_.GetContent(), GetDataset(parsed_.GetContent())))
        {
          LOG(ERROR) << "Unable to serialize a DICOM file to a memory buffer";
          throw OrthancException(ErrorCode_InternalError);
        }
      }
    }

    if (summary_.HasContent() &&
        json_.HasContent())
    {
      return;
    }

    // At this point, we know that the DICOM file is available as a
    // memory buffer, but that its summary or its JSON version is
    // missing

    if (!parsed_.HasContent())
    {
      parsed_.TakeOwnership(new ParsedDicomFile(buffer_.GetConstContent()));
    }

    // At this point, we have parsed the DICOM file
    
    if (!summary_.HasContent())
    {
      summary_.Allocate();
      FromDcmtkBridge::Convert(summary_.GetContent(), GetDataset(parsed_.GetContent()));
    }
    
    if (!json_.HasContent())
    {
      json_.Allocate();
      FromDcmtkBridge::ToJson(json_.GetContent(), GetDataset(parsed_.GetContent()));
    }
  }
开发者ID:dhanzhang,项目名称:orthanc,代码行数:57,代码来源:DicomInstanceToStore.cpp


示例14: LoadEngine

    static ENGINE* LoadEngine()
    {
      // This function creates an engine for PKCS#11 and inspired by
      // the "ENGINE_load_dynamic" function from OpenSSL, in file
      // "crypto/engine/eng_dyn.c"

      ENGINE* engine = ENGINE_new();
      if (!engine)
      {
        LOG(ERROR) << "Cannot create an OpenSSL engine for PKCS#11";
        throw OrthancException(ErrorCode_InternalError);
      }

      // Create a PKCS#11 context using libp11
      context_ = pkcs11_new();
      if (!context_)
      {
        LOG(ERROR) << "Cannot create a libp11 context for PKCS#11";
        ENGINE_free(engine);
        throw OrthancException(ErrorCode_InternalError);
      }

      if (!ENGINE_set_id(engine, PKCS11_ENGINE_ID) ||
          !ENGINE_set_name(engine, PKCS11_ENGINE_NAME) ||
          !ENGINE_set_cmd_defns(engine, PKCS11_ENGINE_COMMANDS) ||

          // Register the callback functions
          !ENGINE_set_init_function(engine, EngineInitialize) ||
          !ENGINE_set_finish_function(engine, EngineFinalize) ||
          !ENGINE_set_destroy_function(engine, EngineDestroy) ||
          !ENGINE_set_ctrl_function(engine, EngineControl) ||
          !ENGINE_set_load_pubkey_function(engine, EngineLoadPublicKey) ||
          !ENGINE_set_load_privkey_function(engine, EngineLoadPrivateKey) ||

          !ENGINE_set_RSA(engine, PKCS11_get_rsa_method()) ||
          !ENGINE_set_ECDSA(engine, PKCS11_get_ecdsa_method()) ||
          !ENGINE_set_ECDH(engine, PKCS11_get_ecdh_method()) ||

#if OPENSSL_VERSION_NUMBER  >= 0x10100002L
          !ENGINE_set_EC(engine, PKCS11_get_ec_key_method()) ||
#endif

          // Make OpenSSL know about our PKCS#11 engine
          !ENGINE_add(engine))
      {
        LOG(ERROR) << "Cannot initialize the OpenSSL engine for PKCS#11";
        pkcs11_finish(context_);
        ENGINE_free(engine);
        throw OrthancException(ErrorCode_InternalError);
      }

      // If the "ENGINE_add" worked, it gets a structural
      // reference. We release our just-created reference.
      ENGINE_free(engine);

      return ENGINE_by_id(PKCS11_ENGINE_ID);
    }
开发者ID:PACSinTERRA,项目名称:orthanc,代码行数:57,代码来源:Pkcs11.cpp


示例15: OrthancException

  void Toolbox::SplitUriComponents(UriComponents& components,
                                   const std::string& uri)
  {
    static const char URI_SEPARATOR = '/';

    components.clear();

    if (uri.size() == 0 ||
        uri[0] != URI_SEPARATOR)
    {
      throw OrthancException(ErrorCode_UriSyntax);
    }

    // Count the number of slashes in the URI to make an assumption
    // about the number of components in the URI
    unsigned int estimatedSize = 0;
    for (unsigned int i = 0; i < uri.size(); i++)
    {
      if (uri[i] == URI_SEPARATOR)
        estimatedSize++;
    }

    components.reserve(estimatedSize - 1);

    unsigned int start = 1;
    unsigned int end = 1;
    while (end < uri.size())
    {
      // This is the loop invariant
      assert(uri[start - 1] == '/' && (end >= start));

      if (uri[end] == '/')
      {
        components.push_back(std::string(&uri[start], end - start));
        end++;
        start = end;
      }
      else
      {
        end++;
      }
    }

    if (start < uri.size())
    {
      components.push_back(std::string(&uri[start], end - start));
    }

    for (size_t i = 0; i < components.size(); i++)
    {
      if (components[i].size() == 0)
      {
        // Empty component, as in: "/coucou//e"
        throw OrthancException(ErrorCode_UriSyntax);
      }
    }
  }
开发者ID:gbanana,项目名称:orthanc,代码行数:57,代码来源:Toolbox.cpp


示例16: args

  void Toolbox::ExecuteSystemCommand(const std::string& command,
                                     const std::vector<std::string>& arguments)
  {
    // Convert the arguments as a C array
    std::vector<char*>  args(arguments.size() + 2);

    args.front() = const_cast<char*>(command.c_str());

    for (size_t i = 0; i < arguments.size(); i++)
    {
      args[i + 1] = const_cast<char*>(arguments[i].c_str());
    }

    args.back() = NULL;

    int status;

#if defined(_WIN32)
    // http://msdn.microsoft.com/en-us/library/275khfab.aspx
    status = static_cast<int>(_spawnvp(_P_OVERLAY, command.c_str(), &args[0]));

#else
    int pid = fork();

    if (pid == -1)
    {
      // Error in fork()
#if HAVE_GOOGLE_LOG == 1
      LOG(ERROR) << "Cannot fork a child process";
#endif

      throw OrthancException(ErrorCode_SystemCommand);
    }
    else if (pid == 0)
    {
      // Execute the system command in the child process
      execvp(command.c_str(), &args[0]);

      // We should never get here
      _exit(1);
    }
    else
    {
      // Wait for the system command to exit
      waitpid(pid, &status, 0);
    }
#endif

    if (status != 0)
    {
#if HAVE_GOOGLE_LOG == 1
      LOG(ERROR) << "System command failed with status code " << status;
#endif

      throw OrthancException(ErrorCode_SystemCommand);
    }
  }
开发者ID:gbanana,项目名称:orthanc,代码行数:57,代码来源:Toolbox.cpp


示例17: GetPath

  std::string FileStorage::CreateFileWithoutCompression(const void* content, size_t size)
  {
    std::string uuid;
    boost::filesystem::path path;
    
    for (;;)
    {
      uuid = Toolbox::GenerateUuid();
      path = GetPath(uuid);

      if (!boost::filesystem::exists(path))
      {
        // OK, this is indeed a new file
        break;
      }

      // Extremely improbable case: This Uuid has already been created
      // in the past. Try again.
    }

    if (boost::filesystem::exists(path.parent_path()))
    {
      if (!boost::filesystem::is_directory(path.parent_path()))
      {
        throw OrthancException("The subdirectory to be created is already occupied by a regular file");        
      }
    }
    else
    {
      if (!boost::filesystem::create_directories(path.parent_path()))
      {
        throw OrthancException("Unable to create a subdirectory in the file storage");        
      }
    }

    boost::filesystem::ofstream f;
    f.open(path, std::ofstream::out | std::ios::binary);
    if (!f.good())
    {
      throw OrthancException("Unable to create a new file in the file storage");
    }

    if (size != 0)
    {
      f.write(static_cast<const char*>(content), size);
      if (!f.good())
      {
        f.close();
        throw OrthancException("Unable to write to the new file in the file storage");
      }
    }

    f.close();

    return uuid;
  } 
开发者ID:amirkogithub,项目名称:orthanc,代码行数:56,代码来源:FileStorage.cpp


示例18: LOG

  void ZlibCompressor::Uncompress(std::string& uncompressed,
                                  const void* compressed,
                                  size_t compressedSize)
  {
    if (compressedSize == 0)
    {
      uncompressed.clear();
      return;
    }

    if (!HasPrefixWithUncompressedSize())
    {
      LOG(ERROR) << "Cannot guess the uncompressed size of a zlib-encoded buffer";
      throw OrthancException(ErrorCode_InternalError);
    }

    uint64_t uncompressedSize = ReadUncompressedSizePrefix(compressed, compressedSize);
    
    try
    {
      uncompressed.resize(static_cast<size_t>(uncompressedSize));
    }
    catch (...)
    {
      throw OrthancException(ErrorCode_NotEnoughMemory);
    }

    uLongf tmp = static_cast<uLongf>(uncompressedSize);
    int error = uncompress
      (reinterpret_cast<uint8_t*>(&uncompressed[0]), 
       &tmp,
       reinterpret_cast<const uint8_t*>(compressed) + sizeof(uint64_t),
       compressedSize - sizeof(uint64_t));

    if (error != Z_OK)
    {
      uncompressed.clear();

      switch (error)
      {
      case Z_DATA_ERROR:
        throw OrthancException(ErrorCode_CorruptedFile);

      case Z_MEM_ERROR:
        throw OrthancException(ErrorCode_NotEnoughMemory);

      default:
        throw OrthancException(ErrorCode_InternalError);
      }  
    }
  }
开发者ID:milhcbt,项目名称:OrthancMirror,代码行数:51,代码来源:ZlibCompressor.cpp


示例19: OrthancException

  void ZlibCompressor::Uncompress(std::string& uncompressed,
                                  const void* compressed,
                                  size_t compressedSize)
  {
    if (compressedSize == 0)
    {
      uncompressed.clear();
      return;
    }

    if (compressedSize < sizeof(size_t))
    {
      throw OrthancException("Zlib: The compressed buffer is ill-formed");
    }

    size_t uncompressedLength;
    memcpy(&uncompressedLength, compressed, sizeof(size_t));
    
    try
    {
      uncompressed.resize(uncompressedLength);
    }
    catch (...)
    {
      throw OrthancException("Zlib: Corrupted compressed buffer");
    }

    uLongf tmp = uncompressedLength;
    int error = uncompress
      (reinterpret_cast<uint8_t*>(&uncompressed[0]), 
       &tmp,
       reinterpret_cast<const uint8_t*>(compressed) + sizeof(size_t),
       compressedSize - sizeof(size_t));

    if (error != Z_OK)
    {
      uncompressed.clear();

      switch (error)
      {
      case Z_DATA_ERROR:
        throw OrthancException("Zlib: Corrupted or incomplete compressed buffer");

      case Z_MEM_ERROR:
        throw OrthancException(ErrorCode_NotEnoughMemory);

      default:
        throw OrthancException(ErrorCode_InternalError);
      }  
    }
  }
开发者ID:freemed,项目名称:orthanc,代码行数:51,代码来源:ZlibCompressor.cpp


示例20: GetPath

void FilesystemStorage::Create(const std::string& uuid,
                               const void* content,
                               size_t size,
                               FileContentType /*type*/)
{
    boost::filesystem::path path;

    path = GetPath(uuid);

    if (boost::filesystem::exists(path))
    {
        // Extremely unlikely case: This Uuid has already been created
        // in the past.
        throw OrthancException(ErrorCode_InternalError);
    }

    if (boost::filesystem::exists(path.parent_path()))
    {
        if (!boost::filesystem::is_directory(path.parent_path()))
        {
            throw OrthancException("The subdirectory to be created is already occupied by a regular file");
        }
    }
    else
    {
        if (!boost::filesystem::create_directories(path.parent_path()))
        {
            throw OrthancException("Unable to create a subdirectory in the file storage");
        }
    }

    boost::filesystem::ofstream f;
    f.open(path, std::ofstream::out | std::ios::binary);
    if (!f.good())
    {
        throw OrthancException("Unable to create a new file in the file storage");
    }

    if (size != 0)
    {
        f.write(static_cast<const char*>(content), size);
        if (!f.good())
        {
            f.close();
            throw OrthancException("Unable to write to the new file in the file storage");
        }
    }

    f.close();
}
开发者ID:vinayvenu,项目名称:orthanc,代码行数:50,代码来源:FilesystemStorage.cpp



注:本文中的OrthancException函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ OsSchedUnlock函数代码示例发布时间:2022-05-30
下一篇:
C++ Ord函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap