Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

[python] extended xbmcvfs with stat #1537

Merged
merged 1 commit into from

3 participants

@tamland
Collaborator

Probably not the prettiest api but this seems to be what you can currently do with the code generation.

Replaces #1062

@jimfcarroll
Collaborator

Do you prefer to use a tuple like you did in your previous implementation? That should be easy (I would just need to extend the Tuple<> type parameters length).

@tamland
Collaborator

No I only made the previous one a tuple because it was the easiest then. Now, as long as the tuples are unnamed, I would say an object is better because that unpacking line will be pretty long and easy to mess up.

@amet

looks ok to me, cant comment on the code generator details, thats @jimfcarroll

@jimfcarroll jimfcarroll was assigned
@jimfcarroll jimfcarroll merged commit a4acb0c into xbmc:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 5, 2012
  1. @tamland

    extend xbmcvfs with stat

    tamland authored
This page is out of date. Refresh to see the latest.
View
65 xbmc/interfaces/legacy/Stat.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2005-2012 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#pragma once
+
+#include "filesystem/File.h"
+#include "AddonClass.h"
+#include "LanguageHook.h"
+
+namespace XBMCAddon
+{
+ namespace xbmcvfs
+ {
+ /**
+ * Stat(path) -- Get file or file system status.
+ *
+ * path : file or folder
+ *
+ * example:
+ * st = xbmcvfs.Stat(path)
+ * modified = st.st_mtime()
+ */
+ class Stat : public AddonClass
+ {
+ struct __stat64 st;
+
+ public:
+ Stat(const String& path) : AddonClass("Stat")
+ {
+ DelayedCallGuard dg;
+ XFILE::CFile::Stat(path, &st);
+ }
+
+ inline long long st_mode() { return st.st_mode; };
+ inline long long st_ino() { return st.st_ino; };
+ inline long long st_dev() { return st.st_dev; };
+ inline long long st_nlink() { return st.st_nlink; };
+ inline long long st_uid() { return st.st_uid; };
+ inline long long st_gid() { return st.st_gid; };
+ inline long long st_size() { return st.st_size; };
+ inline long long atime() { return st.st_atime; }; //names st_atime/st_mtime/st_ctime are used by sys/stat.h
+ inline long long mtime() { return st.st_mtime; };
+ inline long long ctime() { return st.st_ctime; };
+ };
+ }
+}
+
View
6 xbmc/interfaces/swig/AddonModuleXbmcvfs.i
@@ -24,6 +24,7 @@
%{
#include "interfaces/legacy/ModuleXbmcvfs.h"
#include "interfaces/legacy/File.h"
+#include "interfaces/legacy/Stat.h"
#include "utils/log.h"
using namespace XBMCAddon;
@@ -72,6 +73,11 @@ using namespace xbmcvfs;
%include "interfaces/legacy/File.h"
+%rename ("st_atime") XBMCAddon::xbmcvfs::Stat::atime;
+%rename ("st_mtime") XBMCAddon::xbmcvfs::Stat::mtime;
+%rename ("st_ctime") XBMCAddon::xbmcvfs::Stat::ctime;
+%include "interfaces/legacy/Stat.h"
+
%rename ("delete") XBMCAddon::xbmcvfs::deleteFile;
%include "interfaces/legacy/ModuleXbmcvfs.h"
Something went wrong with that request. Please try again.