~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to drizzled/function/str/load_file.cc

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-06-19 10:46:49 UTC
  • mfrom: (1.1.6)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20120619104649-e2l0ggd4oz3um0f4
Tags: upstream-7.1.36-stable
ImportĀ upstreamĀ versionĀ 7.1.36-stable

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
5
 *  Copyright (C) 2011 Stewart Smith
5
6
 *
6
7
 *  This program is free software; you can redistribute it and/or modify
7
8
 *  it under the terms of the GNU General Public License as published by
21
22
#include <drizzled/function/str/strfunc.h>
22
23
#include <drizzled/function/str/load_file.h>
23
24
#include <drizzled/error.h>
24
 
#include <drizzled/data_home.h>
 
25
#include <drizzled/catalog/local.h>
25
26
#include <drizzled/session.h>
26
27
#include <drizzled/internal/my_sys.h>
 
28
#include <drizzled/sys_var.h>
 
29
#include <drizzled/system_variables.h>
27
30
 
28
31
#include <boost/filesystem.hpp>
29
32
 
47
50
  if (!(file_name= args[0]->val_str(str)))
48
51
  {
49
52
    null_value = 1;
50
 
    return(0);
 
53
    return 0;
51
54
  }
52
55
 
53
 
  fs::path target_path(fs::system_complete(getDataHomeCatalog()));
 
56
  fs::path target_path(fs::system_complete(catalog::local_identifier().getPath()));
54
57
  fs::path to_file(file_name->c_ptr());
55
58
  if (not to_file.has_root_directory())
56
59
  {
100
103
    goto err;
101
104
  }
102
105
 
103
 
  if (tmp_value.alloc((size_t)stat_info.st_size))
104
 
    goto err;
 
106
  tmp_value.alloc((size_t)stat_info.st_size);
105
107
  if ((file = internal::my_open(target_path.file_string().c_str(), O_RDONLY, MYF(0))) < 0)
106
108
    goto err;
107
109
  if (internal::my_read(file, (unsigned char*) tmp_value.ptr(), (size_t)stat_info.st_size, MYF(MY_NABP)))
120
122
 
121
123
err:
122
124
  null_value = 1;
123
 
  return(0);
 
125
  return 0;
124
126
}
125
127
 
126
128