2011-02-07 17:39:49 +01:00
|
|
|
// Copyright (c) 2010-2011, Amar Takhar <verm@aegisub.org>
|
2010-05-24 19:57:07 +02:00
|
|
|
//
|
|
|
|
// Permission to use, copy, modify, and distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
|
|
// copyright notice and this permission notice appear in all copies.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
|
|
|
|
/// @file path.cpp
|
|
|
|
/// @brief Common paths.
|
|
|
|
/// @ingroup libaegisub
|
|
|
|
|
|
|
|
|
2011-02-07 18:36:24 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#ifndef LAGI_PRE
|
2011-02-08 05:22:52 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2011-02-07 17:39:49 +01:00
|
|
|
#include <string>
|
2011-02-23 04:24:08 +01:00
|
|
|
#include <vector>
|
2011-02-07 18:36:24 +01:00
|
|
|
#endif
|
|
|
|
|
2010-05-24 19:57:07 +02:00
|
|
|
#include <libaegisub/path.h>
|
|
|
|
|
2011-02-07 18:36:24 +01:00
|
|
|
|
2010-05-24 19:57:07 +02:00
|
|
|
namespace agi {
|
|
|
|
|
2011-02-08 05:22:52 +01:00
|
|
|
|
2011-07-15 06:03:28 +02:00
|
|
|
std::string home() {
|
2011-02-08 05:22:52 +01:00
|
|
|
char *ehome;
|
|
|
|
ehome = getenv("HOME");
|
|
|
|
if (ehome == NULL) {
|
2011-02-08 23:40:55 +01:00
|
|
|
printf("The HOME environment variable must be set\n");
|
|
|
|
exit(1);
|
2011-02-08 05:22:52 +01:00
|
|
|
}
|
2011-07-15 06:03:28 +02:00
|
|
|
return ehome;
|
2011-02-08 05:22:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-15 06:03:28 +02:00
|
|
|
std::string Path::Data() {
|
2011-02-08 05:22:52 +01:00
|
|
|
return P_DATA;
|
2010-05-24 19:57:07 +02:00
|
|
|
}
|
|
|
|
|
2011-07-15 06:03:28 +02:00
|
|
|
std::string Path::Doc() {
|
2011-02-08 05:22:52 +01:00
|
|
|
return P_DOC;
|
2010-05-24 19:57:07 +02:00
|
|
|
}
|
|
|
|
|
2011-07-15 06:03:28 +02:00
|
|
|
std::string Path::User() {
|
2011-02-08 05:22:52 +01:00
|
|
|
return home();
|
2010-05-24 19:57:07 +02:00
|
|
|
}
|
|
|
|
|
2011-07-15 06:03:28 +02:00
|
|
|
std::string Path::Locale() {
|
2011-02-08 05:22:52 +01:00
|
|
|
return P_LOCALE;
|
2010-05-24 19:57:07 +02:00
|
|
|
}
|
|
|
|
|
2011-07-15 06:03:28 +02:00
|
|
|
std::string Path::Config() {
|
2012-08-19 23:33:50 +02:00
|
|
|
return home() + "/.aegisub/";
|
2011-02-07 17:39:49 +01:00
|
|
|
}
|
2010-05-24 19:57:07 +02:00
|
|
|
|
2011-07-15 06:03:28 +02:00
|
|
|
std::string Path::Temp() {
|
2011-02-07 17:39:49 +01:00
|
|
|
return "/tmp/";
|
2010-05-24 19:57:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace agi
|